Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inputFrom = "above"
- outputTo = "below"
- workSlot = 0
- workCount = 0
- craftCount = 0
- leftovers = 0
- function intDiv(number, divisor)
- count = number
- result = 0
- while count >= 9 do
- result = result+1
- count = count - divisor
- end
- return result
- end
- function unloadTurtle()
- for i=1,16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- returnItems()
- end
- end
- end
- function suckItems()
- if inputFrom == "above" then
- turtle.suckUp(9)
- else
- turtle.suck(9)
- end
- end
- function returnItems(count)
- if count == nil then
- count = 64
- end
- if inputFrom == "above" then
- turtle.dropUp(count)
- else
- turtle.drop(count)
- end
- end
- function unloadCraftedItems()
- if outputTo == "front" then
- turtle.drop()
- else
- turtle.dropDown()
- end
- end
- print("Version 0.2")
- while true do
- -- Load items from input chest
- for i=1,16 do
- turtle.select(i)
- suckItems()
- if turtle.getItemCount(i) == 9 then
- workSlot = i
- break
- end
- end
- if workSlot > 0 then
- if workSlot > 0 then
- workCount = turtle.getItemCount(workSlot)
- -- Unload all but the workSlot items
- for i=1,16 do
- if i ~= workSlot then
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- returnItems()
- end
- end
- end
- -- Move work items to slot 16 temporarily
- workCount = turtle.getItemCount(workSlot)
- turtle.select(workSlot)
- turtle.transferTo(16)
- -- Work out the numbers
- craftCount = intDiv(workCount, 9)
- leftovers = workCount - (craftCount * 9)
- -- Put the leftovers back
- turtle.select(16)
- returnItems(leftovers)
- -- Load up the crafting slots
- turtle.transferTo(1, craftCount)
- turtle.transferTo(2, craftCount)
- turtle.transferTo(3, craftCount)
- turtle.transferTo(5, craftCount)
- turtle.transferTo(6, craftCount)
- turtle.transferTo(7, craftCount)
- turtle.transferTo(9, craftCount)
- turtle.transferTo(10, craftCount)
- turtle.transferTo(11, craftCount)
- -- Craft it
- turtle.craft()
- turtle.select(16)
- unloadCraftedItems()
- end
- else
- unloadTurtle()
- sleep(600)
- end
- sleep(0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement