# floor

May 13th, 2013
63
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. turningRight = true -- If the first direction the turtle needs to turn is right, leave this true. Change to false if you need to turn left first.
2. blocksBetweenLanterns = 15 -- Number of blocks between placing torches
3.
4. blocksSinceLastLantern = 0
5. while true do
6.
7. -- Place a block below and 2 blocks above
8. turtle.placeDown()
9. turtle.up()
10. turtle.placeUp()
11. turtle.down()
12.
13. -- Figure out if we need to place a lantern
14. blocksSinceLastLantern = blocksSinceLastLantern + 1
15. if blocksSinceLastLantern > blocksBetweenLanterns then
16. if turtle.getItemCount(9) == 0 then
17. print("Out of Lanterns")
18. print("Place some in slot 9")
19. print("and press ENTER to continue")
21. end
22. turtle.turnRight()
23. turtle.turnRight()
24. turtle.select(9)
25. turtle.place()
26. turtle.select(1)
27. turtle.turnRight()
28. turtle.turnRight()
29. blocksSinceLastLantern = 0
30. end
31.
32. -- If we can't move forward, start the process of moving unto the next row
33. if turtle.forward() == false then
34.
35. -- Check which direction we need to turn
36. if turningRight == true then
37.
38. -- Turn Right
39. turtle.turnRight()
40. if turtle.forward() == false then
41. clearToContinue = false
42. while clearToContinue == false do
43. turtle.turnRight()
44. turtle.forward()
45. turtle.turnLeft()
46. if turtle.forward() == true then
47. clearToContinue = true
48. end
49. end
50. end
51. turtle.turnLeft()
52. turningRight = false
53. else
54.
55. -- Turn Left
56. turtle.turnLeft()
57. if turtle.forward() == false then
58. clearToContinue = false
59. while clearToContinue == false do
60. turtle.turnLeft()
61. turtle.forward()
62. turtle.turnRight()
63. if turtle.forward() == true then
64. clearToContinue = true
65. end
66. end
67. end
68. turtle.turnRight()
69. turningRight = true
70. end
71.
72. -- Move forward until we hit the wall of the new row
73. while turtle.detect() == false do
74. turtle.forward()
75. end
76.
77. -- Turn around
78. turtle.turnRight()
79. turtle.turnRight()
80.
81. end
82.
83. -- Check to make sure the inventory has materials
84. inventoryEmpty = true
85. for i=1,9 do
86. if turtle.getItemCount(i) > 0 then
87. inventoryEmpty = false
88. break
89. end
90. end
91.
92. -- Pause if we ran out of stuff
93. if inventoryEmpty == true then
94. print("Need More Blocks!")
95. print("Press Enter To Continue...")