Advertisement
k2green

CCTweaked fluix crystal crafting

Jul 30th, 2024
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | Software | 0 0
  1. local function getFluixSlots()
  2.     local chest = peripheral.wrap("front")
  3.     local data = {
  4.         ["totals"] = {
  5.             ["quartz"] = 0,
  6.             ["redstone"] = 0,
  7.             ["ccq"] = 0
  8.         }
  9.     }
  10.    
  11.     for i=1, chest.size() do
  12.         local details = chest.getItemDetail(i)
  13.        
  14.         if details ~= nil then
  15.             if details.name == "minecraft:quartz" then
  16.                 if data.quartz == nil then
  17.                     data.quartz = { { ["slot"] = i, ["count"] = details.count } }
  18.                 else
  19.                     table.insert(data.quartz, { ["slot"] = i, ["count"] = details.count })
  20.                 end
  21.             elseif details.name == "minecraft:redstone" then
  22.                 if data.redstone == nil then
  23.                     data.redstone = { { ["slot"] = i, ["count"] = details.count } }
  24.                 else
  25.                     table.insert(data.redstone, { ["slot"] = i, ["count"] = details.count })
  26.                 end
  27.             elseif details.name == "ae2:charged_certus_quartz_crystal" then
  28.                 if data.ccq == nil then
  29.                     data.ccq = { { ["slot"] = i, ["count"] = details.count } }
  30.                 else
  31.                     table.insert(data.ccq, { ["slot"] = i, ["count"] = details.count })
  32.                 end
  33.             end
  34.         end
  35.     end
  36.    
  37.     for k,v in ipairs(data.quartz) do
  38.         data.totals.quartz = data.totals.quartz + v.count
  39.     end
  40.    
  41.     for k,v in ipairs(data.redstone) do
  42.         data.totals.redstone = data.totals.redstone + v.count
  43.     end
  44.    
  45.     for k,v in ipairs(data.ccq) do
  46.         data.totals.ccq = data.totals.ccq + v.count
  47.     end
  48.    
  49.     local canCraft = data.totals.quartz > 0 and data.totals.redstone > 0 and data.totals.ccq > 0
  50.    
  51.     if canCraft then
  52.         return true, data
  53.     else
  54.         return false, nil
  55.     end
  56. end
  57.  
  58. local function getItems(name, count, data)
  59.     local chest = peripheral.wrap("front")
  60.     for k,v in ipairs(data[name]) do
  61.         local amount = math.min(count, v.count)
  62.         chest.pushItems("top", v.slot, amount, 1)
  63.        
  64.         count = count - amount
  65.         if count < 1 then
  66.             break
  67.         end
  68.     end
  69.    
  70.     turtle.suckUp(64)
  71. end
  72.  
  73. local function makeFluix()
  74.     turtle.select(1)
  75.     turtle.drop(1)
  76.     turtle.select(2)
  77.     turtle.drop(1)
  78.     turtle.select(3)
  79.     turtle.drop(1)
  80.     turtle.select(4)
  81.    
  82.     sleep(4)
  83.    
  84.     turtle.suck(2)
  85. end
  86.  
  87. while true do
  88.     local canCraft, data = getFluixSlots()
  89.     if canCraft then
  90.         local craftAmount = math.min(32, data.totals.quartz, data.totals.redstone, data.totals.ccq)
  91.        
  92.         turtle.select(1)
  93.         getItems("quartz", craftAmount, data)
  94.         turtle.select(2)
  95.         getItems("redstone", craftAmount, data)
  96.         turtle.select(3)
  97.         getItems("ccq", craftAmount, data)
  98.        
  99.         turtle.turnRight()
  100.         for i = 1, craftAmount do
  101.             makeFluix()
  102.         end
  103.        
  104.         turtle.turnLeft()
  105.         turtle.select(4)
  106.         turtle.drop(64)
  107.     end
  108.    
  109.     sleep(5)
  110. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement