JoshuaB

Wall Placer (ComputerCraft)

Feb 10th, 2013
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. local slot = 1
  2. local levels = 2
  3.  
  4. function turnAround()
  5.   turtle.turnLeft()
  6.   turtle.turnLeft()
  7. end
  8.  
  9. function placeToEnd()
  10.   while true do
  11.     items = turtle.getItemCount(slot)
  12.     if items == 0 then
  13.       if slot == 16 then
  14.         print("Out of all bricks")
  15.         return false
  16.       else
  17.         slot = slot + 1
  18.         turtle.select(slot)
  19.         print("Selected slot #", slot)
  20.       end
  21.     else
  22.       moved = turtle.back()
  23.       if not moved then
  24.         return true
  25.       end
  26.  
  27.       turtle.place()
  28.     end
  29.   end
  30. end
  31.  
  32. -- Run into wall
  33. turtle.select(slot)
  34. for i=1,levels do
  35.   out = placeToEnd()
  36.   if not out then
  37.     break
  38.   end
  39.  
  40.   print("Moving up level")
  41.   turtle.up()
  42.   turnAround()
  43. end
Advertisement
Add Comment
Please, Sign In to add comment