Advertisement
labrecquev

Land Fill

Mar 25th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. function landfill()
  2. --turtle.select(1)
  3. for a=1,width do
  4. for b=1,length do
  5. if turtle.detectDown() then
  6. turtle.forward()
  7. else
  8. checkslots()
  9. turtle.placeDown()
  10. turtle.forward()
  11. end
  12. end
  13. checkslots()
  14. if a % 2 == 0 then
  15. --turn left
  16. turtle.turnLeft()
  17. turtle.placeDown()
  18. turtle.forward()
  19. turtle.placeDown()
  20. turtle.turnLeft()
  21. else
  22. turtle.turnRight()
  23. turtle.placeDown()
  24. turtle.forward()
  25. turtle.placeDown()
  26. turtle.turnRight()
  27. end
  28. end
  29. end
  30.  
  31. function wait()
  32. print("ran out of material, waiting...")
  33. repeat
  34. local event,key = os.pullEvent("key")
  35.  
  36. until key == keys.enter
  37.  
  38.  
  39. end
  40.  
  41. function checkslots()
  42. for i=1,16 do
  43. if turtle.getItemCount(i)==0 then
  44. return
  45. else
  46. turtle.select(i)
  47. end
  48. end
  49. if turtle.getItemCount(turtle.getSelectedSlot()) == 0 then
  50. wait()
  51. end
  52. end
  53.  
  54. print("Welcome to the land filling program.")
  55. print("How far to go?")
  56. length = tonumber(read())
  57. print("Ok, I will go that far: ", length)
  58.  
  59. print("How wide right?")
  60. width = tonumber(read())
  61. print("Ok, I will go that wide right: ", width)
  62. print("Ready? y/n")
  63. ready = read()
  64.  
  65.  
  66. if (ready == "y") then
  67. print("Alright, starting...")
  68. landfill()
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement