Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Automatic crafting system. Used for crafting ore blocks.
- local tableSlots = {1,2,3,5,6,7,9,10,11}
- local a = 1
- local function craft(slot)
- local b = turtle.getItemCount(slot)
- local reps = (b - math.fmod(b,9)) / 9 --Figure out amount of blocks to create
- if slot ~= 16 then --Make sure the crafting materials are in slot 16
- turtle.select(16)
- turtle.dropDown()
- turtle.select(slot)
- turtle.transferTo(16)
- end
- for i = 1,16 do --Set up the crafting grid
- turtle.select(i)
- turtle.dropDown() --Clear the slots
- if i == tableSlots[a] then
- turtle.select(16)
- turtle.transferTo(tableSlots[a], reps) --Transfer materials to the crafting slots
- a = a + 1
- end
- end
- turtle.select(1)
- a = 1
- if turtle.craft() then --If it crafted, move to a chest in front
- turtle.drop()
- else --If not, empty grid
- for i = 1,9 do
- turtle.select(tableSlots[i])
- turtle.drop()
- end
- end
- for i = 1,16 do
- turtle.suckDown()
- end
- end
- while true do
- turtle.suckDown()
- for j = 1,16 do
- if turtle.getItemCount(j) >= 9 then
- craft(j)
- break
- end
- end
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment