Advertisement
mitchfizz05

Untitled

Jul 12th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. -- Mitchfizz05's elevator turtle
  2.  
  3. local floorSpacing = 4
  4.  
  5. local function home()
  6. print("Homing turtle to ground floor...")
  7. currentFloor = 0
  8. while turtle.down() do end
  9. end
  10.  
  11. home()
  12.  
  13. local function mainLoop()
  14. term.clear()
  15. term.setCursorPos(1,1)
  16. print("Elevator turtle")
  17. print()
  18.  
  19. term.write(" Enter floor number: ")
  20. local floorNum = tonumber(read())
  21. if (floorNum == nil) then
  22. print("Invalid floor number")
  23. sleep(0.75)
  24. return
  25. end
  26.  
  27. floorNum = floorNum - 1
  28.  
  29. -- Go up to target floor
  30. for i = 1, (floorNum * floorSpacing), 1 do
  31. while not turtle.up() do end
  32. end
  33.  
  34. print("You have arrived!")
  35. sleep(2)
  36. home()
  37. end
  38.  
  39. while true do
  40. mainLoop()
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement