Advertisement
Zantag

Alveary Placer

Jun 19th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.16 KB | None | 0 0
  1. -- Slots for items (Slots for config options can be changed in the config itself)
  2. fuelSlot = 16
  3. alvearyBlockSlot = 15
  4. oakSlabSlot = 14
  5.  
  6. -- Config
  7. config = {
  8. addFrameHousings = {enabled = true, slot = 13}
  9. }
  10.  
  11. -- Functions
  12. -- General functions
  13. function fuel()
  14. if turtle.getFuelLevel() == 0 then
  15. if turtle.getItemCount(fuelSlot) == 0 then
  16. error("No fuel left.")
  17. else
  18. turtle.select(fuelSlot)
  19. turtle.refuel(1)
  20. end
  21. end
  22. end
  23.  
  24. -- Movement functions
  25. function right()
  26. turtle.turnRight()
  27.  
  28. if turtle.detect() then
  29. turtle.dig()
  30. end
  31.  
  32. fuel()
  33. turtle.forward()
  34. end
  35.  
  36. function left()
  37. turtle.turnLeft()
  38.  
  39. if turtle.detect() then
  40. turtle.dig()
  41. end
  42.  
  43. fuel()
  44. turtle.forward()
  45. end
  46.  
  47. function back()
  48. turtle.turnRight()
  49. turtle.turnRight()
  50.  
  51. if turtle.detect() then
  52. turtle.dig()
  53. end
  54.  
  55. fuel()
  56. turtle.forward()
  57.  
  58. turtle.turnLeft()
  59. turtle.turnLeft()
  60.  
  61. end
  62.  
  63. function forward()
  64. if turtle.detect() then
  65. turtle.dig()
  66. end
  67. fuel()
  68. turtle.forward()
  69. end
  70.  
  71. function up()
  72. if turtle.detectUp() then
  73. turtle.digUp()
  74. end
  75. fuel()
  76. turtle.up()
  77. end
  78.  
  79. function down()
  80. if turtle.detectDown() then
  81. turtle.digDown()
  82. end
  83. fuel()
  84. turtle.down()
  85. end
  86.  
  87. -- Alveary building functions
  88. function placeAlvBlock()
  89. if turtle.getItemCount(alvearyBlockSlot) == 0 then
  90. error("No alveary blocks left.")
  91. else
  92. if turtle.detectDown() then
  93. turtle.digDown()
  94. end
  95.  
  96. turtle.select(alvearyBlockSlot)
  97. turtle.placeDown()
  98. end
  99. end
  100.  
  101. function placeSlab()
  102. if turtle.getItemCount(oakSlabSlot) == 0 then
  103. error("No oak wood slabs left.")
  104. else
  105. if turtle.detectDown() then
  106. turtle.digDown()
  107. end
  108.  
  109. turtle.select(oakSlabSlot)
  110. turtle.placeDown()
  111. end
  112. end
  113.  
  114. function placeFrameHous()
  115. if config.addFrameHousings.enabled then
  116. if turtle.getItemCount(config.addFrameHousings.slot) == 0 then
  117. error("No frame housings left.")
  118. else
  119. if turtle.detectDown() then
  120. turtle.digDown()
  121. end
  122.  
  123. turtle.select(config.addFrameHousings.slot)
  124. turtle.placeDown()
  125. end
  126. else
  127. placeAlvBlock()
  128. end
  129. end
  130.  
  131. function buildAlveary()
  132. -- Starts from the middle of the first side of the alveary
  133. -- New First layer
  134. up()
  135. placeAlvBlock()
  136. forward()
  137. placeAlvBlock()
  138. right()
  139. placeAlvBlock()
  140. right()
  141. placeAlvBlock()
  142. forward()
  143. placeAlvBlock()
  144. right()
  145. placeAlvBlock()
  146. forward()
  147. placeAlvBlock()
  148. right()
  149. placeAlvBlock()
  150. forward()
  151. placeAlvBlock()
  152. right()
  153. right()
  154. turtle.turnRight()
  155. turtle.turnRight()
  156. up()
  157. -- New Second layer
  158. back()
  159. placeAlvBlock()
  160. right()
  161. placeFrameHous()
  162. left()
  163. placeFrameHous()
  164. forward()
  165. placeFrameHous()
  166. left()
  167. placeFrameHous()
  168. forward()
  169. placeFrameHous()
  170. left()
  171. placeAlvBlock()
  172. forward()
  173. placeAlvBlock()
  174. left()
  175. left()
  176. placeFrameHous()
  177.  
  178. up()
  179.  
  180. -- Third layer
  181. placeAlvBlock()
  182. forward()
  183. placeAlvBlock()
  184. right()
  185. placeAlvBlock()
  186. right()
  187. placeAlvBlock()
  188. forward()
  189. placeAlvBlock()
  190. right()
  191. placeAlvBlock()
  192. forward()
  193. placeAlvBlock()
  194. right()
  195. placeAlvBlock()
  196. forward()
  197. placeAlvBlock()
  198. right()
  199. right()
  200. turtle.turnRight()
  201. turtle.turnRight()
  202. up()
  203. -- Oak slabs
  204. placeSlab()
  205. forward()
  206. placeSlab()
  207. right()
  208. placeSlab()
  209. right()
  210. placeSlab()
  211. forward()
  212. placeSlab()
  213. right()
  214. placeSlab()
  215. forward()
  216. placeSlab()
  217. right()
  218. placeSlab()
  219. forward()
  220. placeSlab()
  221. right()
  222. right()
  223. turtle.turnRight()
  224. turtle.turnRight()
  225. end
  226.  
  227. function putInPosition()
  228. -- Puts itself in position to make another alveary in a line
  229. forward()
  230. forward()
  231. for i = 1, 4 do
  232. down()
  233. end
  234. forward()
  235. forward()
  236. forward()
  237. end
  238. -- Main program
  239. local tArgs = {...}
  240.  
  241. -- Makes as many alvearies as was passed to it in a straight line, with 2 spaces in between
  242. count = int
  243.  
  244. for i = 1, tArgs[1] do
  245. buildAlveary()
  246. putInPosition()
  247. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement