Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------
- -- First argument is the number of craft per time.
- -- The following arguments are the slots that you want to skip based on turtle slot index.
- ----------------------------------------
- local args = {...}
- local iterations = 1
- local numOfItemsPerCraft = tonumber(args[1]) or 64
- if numOfItemsPerCraft > 64 then numOfItemsPerCraft = 64 end
- local defaultSlots = {1,2,3,5,6,7,9,10,11} -- Minecraft default crafting slots
- local craftingSlots = {} -- actual slot that craft
- local slotsToSkip = {}
- if args[2] then
- for i = 2, #args do
- slotsToSkip[i-1] = args[2]
- end
- local skipIndex = 1
- for i = 1, 9 do
- if defaultSlots[i] == slotsToSkip[skipIndex] then
- skipIndex = skipIndex + 1
- else
- craftingSlots[#craftingSlots+1] = defaultSlots[i]
- end
- end
- else
- craftingSlots = defaultSlots
- end
- function suckItems()
- --print("Start sucking items")
- for i = 1, #craftingSlots do
- turtle.select(craftingSlots[i])
- local itemCount = turtle.getItemCount()
- while itemCount < numOfItemsPerCraft do
- local isSuccess = turtle.suckDown(numOfItemsPerCraft-itemCount)
- if isSuccess then itemCount = turtle.getItemCount()
- else sleep(3) end
- end
- end
- craftAndDropItems()
- end
- function craftAndDropItems()
- --print("Start crafting items")
- turtle.select(16)
- turtle.craft()
- turtle.drop()
- iterations = iterations + 1
- if iterations > 64 then
- os.reboot() -- to avoid bug
- else
- suckItems()
- end
- end
- suckItems()
Add Comment
Please, Sign In to add comment