Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local CRAFT_BATCH_SIZE = 16;
- local CRAFT_SLEEP_WAIT = 2;
- local craftTable = {
- {"f", "t", 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0}
- }
- function cleanUpInventory()
- print("[cr] cleaning up the inventory")
- for i=1,16 do
- turtle.select(i)
- turtle.dropDown()
- end
- end
- function loadIngridient(slot, direction)
- if direction == 0 then
- return
- end
- print("[cr] loading item to slot " .. slot)
- turtle.select(slot)
- local res
- local count = turtle.getItemCount()
- if direction == "t" then
- res = turtle.suckUp(CRAFT_BATCH_SIZE - count)
- elseif direction == "b" then
- res = turtle.suckDown(CRAFT_BATCH_SIZE - count)
- elseif direction == "f" then
- res = turtle.suck(CRAFT_BATCH_SIZE - count)
- end
- if not res then
- print("[cr] could not get items to the slot, waiting and trying again...")
- sleep(CRAFT_SLEEP_WAIT)
- return loadIngridient(slot, direction)
- end
- if turtle.getItemCount() < CRAFT_BATCH_SIZE then
- print("[cr] loaded less items then expected, waiting to try fill up fully...")
- sleep(CRAFT_SLEEP_WAIT)
- return loadIngridient(slot, direction)
- end
- end
- function iterate()
- print("[cr] getting ingredients")
- for i,row in ipairs(craftTable) do
- for j,col in ipairs(row) do
- print("[cr] loading into slot " .. j .. ';' .. i);
- loadIngridient(i*4+j, col)
- end
- end
- print("[cr] crafting")
- turtle.select(1)
- turtle.craft()
- print("[cr] pooping out results ...")
- while turtle.getItemCount() > 0 do
- sleep(CRAFT_SLEEP_WAIT)
- end
- end
- function main()
- print("\n\n-------------------------------")
- print("[cr] starting the program; v1.0")
- print("-------------------------------\n\n");
- cleanUpInventory()
- while true do
- iterate()
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement