Guest User

createstairs

a guest
Apr 15th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. write("Number of stair groups: ")
  2. local num = read()
  3. local st = 0
  4. local numSteps = 0
  5. local returnToTop = "no"
  6. for i=1,num do
  7.   for ii=1,3 do
  8.     turtle.forward()
  9.     turtle.down()
  10.     turtle.placeDown()
  11.     if not turtle.placeDown() then
  12.       print("Error - could not place block")
  13.       print("Check fuel level or existing blocks")
  14.       break
  15.     end
  16.   end
  17. turtle.turnRight()
  18. st = st+1
  19.   if st == num then
  20.     print(st.." stair(s) complete!")  
  21.   end
  22. end
  23.  
  24. write("Return to top? (yes/no) ")
  25. returnToTop = read()
  26. if returnToTop == "yes" then
  27.   numSteps = num*3
  28.   print("Returning to top - "..numSteps.." stairs")
  29.   turtle.turnRight()
  30.  
  31.   for i=1,numSteps do
  32.     turtle.up()
  33.     turtle.detect()
  34.     if turtle.detect() then
  35.       turtle.turnLeft()
  36.     end
  37.   turtle.forward()
  38.   end
  39. print("Return to top complete")
  40. end
Advertisement
Add Comment
Please, Sign In to add comment