Advertisement
Guest User

vertical

a guest
Nov 26th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. function findJunkToPlace ()
  2.     for slot = 1, 12, 1 do
  3.         -- compare this slot to each slot in the bottom row
  4.         -- if it matches, leave it selected
  5.         turtle.select(slot)
  6.         for compare_slot = 13, 16, 1 do
  7.             if (turtle.compareTo(compare_slot)) then
  8.                 -- found a match, leave "slot" selected
  9.                 return true
  10.             end
  11.         end
  12.     end
  13.     -- no matches found
  14.     return false
  15. end
  16.  
  17. turtle.refuel()
  18. local max_depth = tonumber(...)
  19. local current_depth = 0
  20.  
  21. -- dig downwards
  22. while (current_depth < max_depth) do
  23.     print("main loop")
  24.     if (turtle.detectDown()) then
  25.         print("dig down")
  26.         turtle.digDown()
  27.     end
  28.     print("move down");
  29.     turtle.down()
  30.     current_depth = current_depth + 1
  31. end
  32.  
  33. print("main loop end")
  34.  
  35. -- travel back up the shaft, placing garbage below as we rise
  36. while (current_depth > 0) do
  37.     print("up loop")
  38.     print("moving up")
  39.     turtle.up()
  40.     current_depth = current_depth - 1
  41.  
  42.     -- any junk left in selected slot?
  43.     if (turtle.getItemCount() < 1) then
  44.         print("nothing in slot")
  45.         -- nope. Let's find another slot
  46.         if (findJunkToPlace() == false) then
  47.             print("no junk found")
  48.             -- ran out of junk to place
  49.             break
  50.         end
  51.     end
  52.     print("placing down")
  53.     turtle.placeDown()
  54. end
  55. print("end run")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement