dealingwith

Stair Builder

Dec 22nd, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. -- fuel in slot 1
  2. -- stairs in slot 2
  3.  
  4. function fuel()
  5.   if turtle.getFuelLevel() < 10 then
  6.     turtle.select(1)
  7.     if turtle.refuel(1) then
  8.       return true
  9.     end
  10.     print("Refuelling failed.")
  11.     return false
  12.   end
  13. end
  14.  
  15. function dig()
  16.   if turtle.detect() then
  17.    turtle.dig()
  18.   end
  19. end
  20.  
  21. function digDown()
  22.   if turtle.detectDown() then
  23.     turtle.digDown()
  24.   end
  25. end
  26.  
  27. function stairMe()
  28.   digDown()
  29.   turtle.select(2)
  30.   turtle.placeDown()
  31. end
  32.  
  33. function moveMe()
  34.   dig()
  35.   turtle.forward()
  36.   turtle.down()
  37. end
  38.  
  39.  
  40.  
  41. floors = 15
  42.  
  43. stairMe()
  44.  
  45.  
  46.  
  47. sides = floors * 4
  48. sidesCompleted = 0
  49. while sides > sidesCompleted do
  50.   fuel()
  51.   moveMe()
  52.   stairMe()
  53.   moveMe()
  54.   stairMe()
  55.   turtle.turnRight()
  56. end
Advertisement
Add Comment
Please, Sign In to add comment