Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sourceChest = "top" --top or bottom
- hasMiniumStone = true
- recipe = {2,5,6,9}
- function emptyInventory(targetChest)
- local f = 1
- if hasMiniumStone == true then
- f = 2
- end
- while f <= 16 do
- if turtle.getItemCount(f) > 0 then
- turtle.select(f)
- if targetChest == "front" then
- turtle.drop()
- elseif targetChest == "bottom" then
- turtle.dropDown()
- elseif targetChest == "top" then
- turtle.dropUp()
- end
- end
- f = f + 1
- end
- end
- function distribute(slots)
- local tempSlot = 1
- if hasMiniumStone == true then
- tempSlot = 2
- end
- turtle.select(tempSlot)
- --Get some items from the source chest
- while turtle.getItemCount(tempSlot) < table.getn(slots) do
- if sourceChest == "top" then
- turtle.suckUp()
- else
- turtle.suckDown()
- end
- end
- --Get rid of what we don't need
- if sourceChest == "top" then
- turtle.dropUp(turtle.getItemCount(tempSlot)-table.getn(slots))
- else
- turtle.dropDown(turtle.getItemCount(tempSlot)-table.getn(slots))
- end
- --Get rid of extra overflow
- if turtle.getItemCount(tempSlot + 1) > 0 then
- turtle.select(tempSlot + 1)
- if sourceChest == "top" then
- turtle.dropUp(turtle.getItemCount(tempSlot + 1))
- else
- turtle.dropDown(turtle.getItemCount(tempSlot + 1))
- end
- end
- --Distribute
- for i,v in ipairs(slots) do
- if v == tempSlot then
- else
- turtle.select(tempSlot)
- turtle.transferTo(v,1)
- end
- end
- end
- function craft()
- turtle.select(1)
- turtle.craft(1)
- end
- print("Emptying inventory in case of reboot")
- emptyInventory(sourceChest)
- while true do
- print("Distributing...")
- distribute(recipe)
- print("Crafting...")
- craft()
- print("Passing new items...")
- emptyInventory("front")
- sleep(0.01)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement