Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function getFluixSlots()
- local chest = peripheral.wrap("front")
- local data = {
- ["totals"] = {
- ["quartz"] = 0,
- ["redstone"] = 0,
- ["ccq"] = 0
- }
- }
- for i=1, chest.size() do
- local details = chest.getItemDetail(i)
- if details ~= nil then
- if details.name == "minecraft:quartz" then
- if data.quartz == nil then
- data.quartz = { { ["slot"] = i, ["count"] = details.count } }
- else
- table.insert(data.quartz, { ["slot"] = i, ["count"] = details.count })
- end
- elseif details.name == "minecraft:redstone" then
- if data.redstone == nil then
- data.redstone = { { ["slot"] = i, ["count"] = details.count } }
- else
- table.insert(data.redstone, { ["slot"] = i, ["count"] = details.count })
- end
- elseif details.name == "ae2:charged_certus_quartz_crystal" then
- if data.ccq == nil then
- data.ccq = { { ["slot"] = i, ["count"] = details.count } }
- else
- table.insert(data.ccq, { ["slot"] = i, ["count"] = details.count })
- end
- end
- end
- end
- for k,v in ipairs(data.quartz) do
- data.totals.quartz = data.totals.quartz + v.count
- end
- for k,v in ipairs(data.redstone) do
- data.totals.redstone = data.totals.redstone + v.count
- end
- for k,v in ipairs(data.ccq) do
- data.totals.ccq = data.totals.ccq + v.count
- end
- local canCraft = data.totals.quartz > 0 and data.totals.redstone > 0 and data.totals.ccq > 0
- if canCraft then
- return true, data
- else
- return false, nil
- end
- end
- local function getItems(name, count, data)
- local chest = peripheral.wrap("front")
- for k,v in ipairs(data[name]) do
- local amount = math.min(count, v.count)
- chest.pushItems("top", v.slot, amount, 1)
- count = count - amount
- if count < 1 then
- break
- end
- end
- turtle.suckUp(64)
- end
- local function makeFluix()
- turtle.select(1)
- turtle.drop(1)
- turtle.select(2)
- turtle.drop(1)
- turtle.select(3)
- turtle.drop(1)
- turtle.select(4)
- sleep(4)
- turtle.suck(2)
- end
- while true do
- local canCraft, data = getFluixSlots()
- if canCraft then
- local craftAmount = math.min(32, data.totals.quartz, data.totals.redstone, data.totals.ccq)
- turtle.select(1)
- getItems("quartz", craftAmount, data)
- turtle.select(2)
- getItems("redstone", craftAmount, data)
- turtle.select(3)
- getItems("ccq", craftAmount, data)
- turtle.turnRight()
- for i = 1, craftAmount do
- makeFluix()
- end
- turtle.turnLeft()
- turtle.select(4)
- turtle.drop(64)
- end
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement