Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findJunkToPlace ()
- for slot = 1, 12, 1 do
- -- compare this slot to each slot in the bottom row
- -- if it matches, leave it selected
- turtle.select(slot)
- for compare_slot = 13, 16, 1 do
- if (turtle.compareTo(compare_slot)) then
- -- found a match, leave "slot" selected
- return true
- end
- end
- end
- -- no matches found
- return false
- end
- turtle.refuel()
- local max_depth = tonumber(...)
- local current_depth = 0
- -- dig downwards
- while (current_depth < max_depth) do
- print("main loop")
- if (turtle.detectDown()) then
- print("dig down")
- turtle.digDown()
- end
- print("move down");
- turtle.down()
- current_depth = current_depth + 1
- end
- print("main loop end")
- -- travel back up the shaft, placing garbage below as we rise
- while (current_depth > 0) do
- print("up loop")
- print("moving up")
- turtle.up()
- current_depth = current_depth - 1
- -- any junk left in selected slot?
- if (turtle.getItemCount() < 1) then
- print("nothing in slot")
- -- nope. Let's find another slot
- if (findJunkToPlace() == false) then
- print("no junk found")
- -- ran out of junk to place
- break
- end
- end
- print("placing down")
- turtle.placeDown()
- end
- print("end run")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement