Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. positionX = 0
  2. positionZ = 0
  3.  
  4. fuelIndex = 7
  5.  
  6. direction = 0
  7. function turnLeft()
  8. direction = direction + 1
  9.  
  10. if direction >= 4 then
  11. direction = 0
  12.  
  13. end
  14.  
  15. turtle.turnLeft()
  16.  
  17. end
  18.  
  19. function turnRight()
  20. direction = direction - 1
  21.  
  22. if direction < 0 then
  23. direction = 3
  24. end
  25.  
  26. turtle.turnRight()
  27.  
  28. end
  29.  
  30. function Move()
  31.  
  32. while turtle.getFuelLevel() <= 0 do
  33. turtle.select(1)
  34. turtle.refuel()
  35. end
  36.  
  37. if turtle.forward() then
  38. if direction == 0 then
  39. positionX = positionX + 1
  40. elseif direction == 1 then
  41. positionZ = positionZ + 1
  42. elseif direction == 2 then
  43. positionX = positionX - 1
  44. elseif direction == 3 then
  45. positionZ = positionZ - 1
  46. else
  47. error("Invalid operation!")
  48. end
  49. end
  50. end
  51.  
  52. function placeSetup()
  53. --inv1 fuel
  54. --inv2 chest
  55. --inv3 turtle
  56. --inv4 diskdrive
  57. --inv5 disk
  58. --inv7-16 coalstacks
  59.  
  60. turtle.select(2)
  61.  
  62. turtle.placeDown()
  63.  
  64. turnLeft()
  65.  
  66. Move()
  67.  
  68. turnLeft()
  69.  
  70. turtle.select(4)
  71. turtle.placeDown()
  72.  
  73. turnRight()
  74.  
  75. turtle.select(5)
  76. turtle.dropDown(1)
  77.  
  78. turnRight()
  79. Move()
  80.  
  81. turnLeft()
  82.  
  83. turtle.select(3)
  84. turtle.placeDown()
  85.  
  86. turtle.select(fuelIndex)
  87. turtle.dropDown()
  88.  
  89. fuelIndex = fuelIndex + 1
  90.  
  91. turnLeft()
  92. Move()
  93.  
  94. sleep(5)
  95.  
  96. turtle.select(5)
  97. turtle.suckDown()
  98.  
  99. turtle.select(4)
  100. turtle.digDown()
  101.  
  102. turnRight()
  103. turnRight()
  104.  
  105. Move()
  106.  
  107. turnRight()
  108. Move()
  109.  
  110. turtle.select(2)
  111.  
  112. turtle.placeDown()
  113.  
  114. turnLeft()
  115.  
  116. for m = 0, 4 do
  117.  
  118. Move()
  119.  
  120. end
  121. end
  122.  
  123. function headBackRow()
  124.  
  125. turnLeft()
  126.  
  127. for l = 0, 5 do
  128. Move()
  129. end
  130.  
  131. turnLeft()
  132.  
  133. while positionX ~= 0 do
  134. Move()
  135. end
  136.  
  137. turnLeft()
  138. turnLeft()
  139.  
  140. end
  141.  
  142. for i = 0, 2 do
  143. for j = 0, 2 do
  144. placeSetup()
  145.  
  146. end
  147.  
  148. headBackRow()
  149.  
  150. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement