Kirkq

Minecraft ComputerCraft Turtle Slime Island

Jul 28th, 2019
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.04 KB | None | 0 0
  1. -- pastebin get d0MzjBzU turt
  2.  
  3. -- Assumptions
  4. -- +Z is towards the sky.
  5. -- +Y is the starting direction.
  6. -- The area is totally clear of blocks, mobs, and players.
  7. -- The Turtle starts above a chest or ender chest outside of the structure at (x,y,z) (+1,-1,+2)
  8. -- The chests are aligned on the X axis with the corresponding item index in the chest
  9. -- Fuel goes in the first chest.
  10. -- The Turtle always places downwards.
  11. -- For consistency it always faces +y when placing a block.
  12.  
  13. -- The Turtle inventory is preloaded with slots 1 through 16 and never runs out from the chest.
  14. -- Slot 1 is fuel. Index 1 is reserved for fuel.
  15.  
  16. --XOOOOO
  17. --XOOOOO
  18. --XOOOOO
  19. --XOOOOO
  20. --XXXXXXX
  21. --XTCCCCCC
  22.  
  23. --Next features:
  24. -- 1: X/Z Flip
  25. -- 2: Threaded Builders
  26.  
  27. -- 3: Better Handling of Fuel Requirements
  28. -- 4: Better Handling of Resource Pickup
  29.  
  30. XHOME = 1
  31. YHOME = -1
  32. ZHOME = 2
  33.  
  34. VERTFLIP = 0
  35.  
  36. local xPos = XHOME
  37. local yPos = YHOME
  38. local zPos = ZHOME
  39. local xDir = 0
  40. local yDir = 1
  41.  
  42. local blockToPlace = 0
  43.  
  44. local debugFlag = 1
  45. local slowMode = 0
  46.  
  47. Array2d = {}
  48.  
  49. --------- Stuff you need to edit ----------
  50.  
  51. -- Test Object
  52.  
  53. blockOrientationMatters = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  54.  
  55. Array2d[1] = {
  56. {"3","0","2"},
  57. {"3","0","0"},
  58. {"2","0","3"},
  59. }
  60.  
  61. Array2d[2] = {
  62. {"3","0","0"},
  63. {"3","2","2"},
  64. {"0","3","3"},
  65. }
  66.  
  67. Array3d = {1,2}
  68.  
  69. XSTRETCH = 2
  70. YSTRETCH = 2
  71. ZSTRETCH = 2
  72. VERTFLIP = 1
  73.  
  74. -- Wednesday Frog
  75.  
  76. --[[
  77.  
  78. --34 x
  79. --27 y
  80.  
  81. blockOrientationMatters = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  82.  
  83. Array2d[1] = {
  84. {"0","0","0","0","0","0","0","0","0","0","0","0","3","3","3","3","3","3","3","3","3","3","3","3","3","3","0","0","0","0","0","0","0","0"},
  85. {"0","0","0","0","0","0","0","0","0","0","3","3","3","2","2","2","2","2","2","2","2","2","2","2","2","3","3","3","3","0","0","0","0","0"},
  86. {"0","0","0","0","0","0","0","0","0","3","3","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","3","3","3","3","0","0"},
  87. {"0","0","0","0","0","0","0","0","3","3","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","3","0","0"},
  88. {"0","0","0","0","0","0","0","3","3","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","3","3","3","3","3","0"},
  89. {"0","0","0","0","0","0","3","3","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","3","3","3","2","2","2","3","0"},
  90. {"0","0","0","0","0","3","3","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","3","3","3","2","2","2","2","2","3","0"},
  91. {"0","0","0","0","3","3","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","3","3","3","2","2","2","2","2","2","2","3","3"},
  92. {"0","0","0","0","3","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","3","3","2","2","2","2","2","2","2","2","2","2","2","3"},
  93. {"0","0","0","3","3","2","3","2","2","2","2","2","2","2","2","2","2","2","2","2","2","3","3","2","2","2","2","2","2","2","2","2","2","3"},
  94. {"0","0","0","3","2","2","2","2","2","2","2","2","2","2","2","2","3","3","3","2","2","2","2","3","2","2","2","2","2","2","2","2","2","3"},
  95. {"0","0","0","3","2","2","2","2","2","2","2","2","3","2","2","3","2","2","2","2","2","2","2","2","3","2","2","2","2","2","2","2","2","3"},
  96. {"0","0","3","3","2","2","2","2","3","2","2","2","2","2","2","3","2","2","2","2","2","2","2","2","2","3","2","2","2","2","2","2","2","3"},
  97. {"0","0","3","2","2","2","2","3","2","2","2","2","2","2","2","3","3","2","2","2","2","2","2","2","2","3","2","2","2","2","2","2","3","3"},
  98. {"0","3","3","2","2","2","2","3","2","2","2","2","2","2","2","2","3","3","3","2","2","2","2","2","3","3","2","2","2","2","2","2","3","0"},
  99. {"0","3","2","3","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","3","2","2","2","3","2","2","2","2","2","2","3","3","0"},
  100. {"3","3","2","2","3","2","2","2","2","2","2","2","2","2","2","2","2","2","3","3","2","2","2","2","3","2","2","2","2","2","3","3","0","0"},
  101. {"3","2","2","2","2","3","3","3","2","2","2","2","2","2","2","3","3","3","2","2","2","2","2","3","3","2","2","2","2","3","3","0","0","0"},
  102. {"3","2","2","3","2","3","0","3","3","3","3","3","3","3","3","2","2","2","2","2","2","2","2","3","2","2","2","2","3","3","0","0","0","0"},
  103. {"3","3","3","3","3","3","0","0","0","0","0","3","2","2","2","2","2","2","2","2","3","3","3","3","3","3","3","3","3","0","0","0","0","0"},
  104. {"0","0","0","0","0","0","0","0","0","0","0","3","3","3","3","3","3","3","3","3","3","0","3","2","2","2","3","0","0","0","0","0","0","0"},
  105. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","3","2","2","2","3","0","0","0","0","0","0","0"},
  106. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","3","3","3","2","2","2","3","0","0","0","0","0","0","0"},
  107. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","3","3","3","2","2","2","2","3","3","0","0","0","0","0","0","0"},
  108. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","3","2","2","2","2","2","3","3","0","0","0","0","0","0","0","0"},
  109. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","3","3","3","2","2","3","3","0","0","0","0","0","0","0","0","0"},
  110. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","3","3","3","3","0","0","0","0","0","0","0","0","0","0"},
  111. }
  112.  
  113. Array3d = {1}
  114.  
  115. XSTRETCH = 1
  116. YSTRETCH = 1
  117. ZSTRETCH = 1
  118.  
  119. --]]
  120.  
  121.  
  122. -- Slime Island
  123.  
  124. --[[
  125.  
  126. blockOrientationMatters = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  127.  
  128. --25 x
  129. --19 y
  130.  
  131. --Slime is
  132. -- 15 x
  133. -- 16 y
  134.  
  135. -- Top
  136. Array2d[1] = {
  137. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  138. {"0","0","0","0","0","0","0","2","2","2","2","2","3","2","2","2","2","2","0","0","0","0","0","0","0"},
  139. {"0","0","0","0","0","2","2","2","2","2","2","2","3","2","2","2","2","2","2","2","0","0","0","0","0"},
  140. {"0","0","0","2","2","2","2","2","2","2","2","2","3","2","2","2","2","2","2","2","2","2","0","0","0"},
  141. {"0","0","2","2","2","2","2","2","2","2","2","3","3","3","2","2","2","2","2","2","2","2","2","0","0"},
  142. {"0","0","2","2","2","2","2","2","2","3","3","3","3","3","3","3","2","2","2","2","2","2","2","0","0"},
  143. {"0","2","2","2","2","2","2","2","3","3","0","0","0","0","0","3","3","2","2","2","2","2","2","2","0"},
  144. {"0","2","2","2","2","2","2","3","3","0","0","0","0","0","0","0","3","3","2","2","2","2","2","2","0"},
  145. {"0","2","2","2","2","2","3","3","0","0","0","0","0","0","0","0","0","3","3","2","2","2","2","2","0"},
  146. {"0","2","2","2","2","3","3","0","0","0","5","0","0","0","5","0","0","0","3","3","2","2","2","2","0"},
  147. {"0","2","2","2","2","3","0","0","0","5","0","5","0","5","0","5","0","0","0","3","2","2","2","2","0"},
  148. {"0","2","2","2","2","3","0","0","0","5","0","5","0","5","0","5","0","0","0","3","2","2","2","2","0"},
  149. {"0","2","2","2","2","3","0","0","4","0","5","0","0","0","5","0","4","0","0","3","2","2","2","2","0"},
  150. {"0","0","2","2","2","3","3","0","4","4","0","0","0","0","0","4","4","0","3","3","2","2","2","0","0"},
  151. {"0","0","2","2","2","2","3","3","3","4","4","4","4","4","4","4","3","3","3","2","2","2","2","0","0"},
  152. {"0","0","0","2","2","2","2","2","3","3","3","3","3","3","3","3","3","2","2","2","2","2","0","0","0"},
  153. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  154. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  155. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"}
  156. }
  157.  
  158. -- Top Minus 1
  159. Array2d[2] = {
  160. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  161. {"0","0","0","0","0","2","2","2","2","2","2","2","3","2","2","2","2","2","2","2","0","0","0","0","0"},
  162. {"0","0","0","2","2","2","2","2","2","2","2","2","3","2","2","2","2","2","2","2","2","2","0","0","0"},
  163. {"0","0","2","2","2","2","2","2","2","2","2","2","3","2","2","2","2","2","2","2","2","2","2","0","0"},
  164. {"0","2","2","2","2","2","2","2","2","2","2","3","3","3","2","2","2","2","2","2","2","2","2","2","0"},
  165. {"0","2","2","2","2","2","2","2","2","3","3","3","3","3","3","3","2","2","2","2","2","2","2","2","0"},
  166. {"2","2","2","2","2","2","2","2","3","3","0","0","0","0","0","3","3","2","2","2","2","2","2","2","2"},
  167. {"2","2","2","2","2","2","2","3","3","0","0","0","0","0","0","0","3","3","2","2","2","2","2","2","2"},
  168. {"2","2","2","2","2","2","3","3","0","0","0","0","0","0","0","0","0","3","3","2","2","2","2","2","2"},
  169. {"2","2","2","2","2","3","3","0","0","0","5","0","0","0","5","0","0","0","3","3","2","2","2","2","2"},
  170. {"2","2","2","2","2","3","0","0","0","5","0","5","0","5","0","5","0","0","0","3","2","2","2","2","2"},
  171. {"2","2","2","2","2","3","0","0","0","5","0","5","0","5","0","5","0","0","0","3","2","2","2","2","2"},
  172. {"2","2","2","2","2","3","0","0","4","0","5","0","0","0","5","0","4","0","0","3","2","2","2","2","2"},
  173. {"0","2","2","2","2","3","3","0","4","4","0","0","0","0","0","4","4","0","3","3","2","2","2","2","0"},
  174. {"0","2","2","2","2","2","3","3","3","4","4","4","4","4","4","4","3","3","3","2","2","2","2","2","0"},
  175. {"0","0","2","2","2","2","2","2","3","3","3","3","3","3","3","3","3","2","2","2","2","2","2","0","0"},
  176. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  177. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  178. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"}
  179. }
  180.  
  181. -- Top Minus 2, same as top minus 1 without center changes, repeats twice.
  182. Array2d[3] = {
  183. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  184. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  185. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  186. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  187. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  188. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  189. {"2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"},
  190. {"2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"},
  191. {"2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"},
  192. {"2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"},
  193. {"2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"},
  194. {"2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"},
  195. {"2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2"},
  196. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  197. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  198. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  199. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  200. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  201. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"}
  202. }
  203.  
  204. -- Top Minus 4, same as top without center changes
  205. Array2d[4] = {
  206. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  207. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  208. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  209. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  210. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  211. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  212. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  213. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  214. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  215. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  216. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  217. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  218. {"0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0"},
  219. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  220. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  221. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  222. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  223. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  224. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"}
  225. }
  226.  
  227. -- Top Minus 5
  228. Array2d[5] = {
  229. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  230. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  231. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  232. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  233. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  234. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  235. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  236. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  237. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  238. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  239. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  240. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  241. {"0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0"},
  242. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  243. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  244. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  245. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  246. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  247. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"}
  248. }
  249.  
  250. -- Top Minus 6
  251. Array2d[6] = {
  252. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  253. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  254. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  255. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  256. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  257. {"0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0"},
  258. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  259. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  260. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  261. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  262. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  263. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  264. {"0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0"},
  265. {"0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0"},
  266. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  267. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  268. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  269. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  270. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"}
  271. }
  272.  
  273. -- Top Minus 7
  274. Array2d[7] = {
  275. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  276. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  277. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  278. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  279. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  280. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  281. {"0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0"},
  282. {"0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0"},
  283. {"0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0"},
  284. {"0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0"},
  285. {"0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0"},
  286. {"0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0"},
  287. {"0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0"},
  288. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  289. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  290. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  291. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  292. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  293. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"}
  294. }
  295.  
  296. -- Top Minus 8
  297. Array2d[8] = {
  298. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  299. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  300. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  301. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  302. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  303. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  304. {"0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0"},
  305. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  306. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  307. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  308. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  309. {"0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0"},
  310. {"0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0"},
  311. {"0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","0","0","0","0","0","0","0"},
  312. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  313. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  314. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  315. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  316. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"}
  317. }
  318.  
  319. -- Empty
  320. Array2d[9] = {
  321. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  322. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  323. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  324. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  325. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  326. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  327. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  328. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  329. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  330. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  331. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  332. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  333. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  334. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  335. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  336. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  337. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  338. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"},
  339. {"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"}
  340. }
  341.  
  342. --Array3d = {9,9,9,9,9,9,9,9,9,9,9,9,8,7,6,5,4,3,3,2,1}
  343.  
  344. --top2 for now
  345. Array3d = {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,2,1}
  346.  
  347. XSTRETCH = 1
  348. YSTRETCH = 1
  349. ZSTRETCH = 1
  350.  
  351. --]]
  352.  
  353. --------- End stuff you need to edit ----------------
  354.  
  355. local XSIZE = table.getn(Array2d[1][1])
  356. local YSIZE = table.getn(Array2d[1])
  357. local ZSIZE = table.getn(Array3d)
  358.  
  359. --123456789abcdefg
  360. --0 denotes empty.
  361. function convertString(str)
  362. if (str == "0") then
  363. ret = 0
  364. elseif (str == "1") then
  365. ret = 1
  366. elseif (str == "2") then
  367. ret = 2
  368. elseif (str == "3") then
  369. ret = 3
  370. elseif (str == "4") then
  371. ret = 4
  372. elseif (str == "5") then
  373. ret = 5
  374. elseif (str == "6") then
  375. ret = 6
  376. elseif (str == "7") then
  377. ret = 7
  378. elseif (str == "8") then
  379. ret = 8
  380. elseif (str == "9") then
  381. ret = 9
  382. elseif (str == "a") then
  383. ret = 10
  384. elseif (str == "b") then
  385. ret = 11
  386. elseif (str == "c") then
  387. ret = 12
  388. elseif (str == "d") then
  389. ret = 13
  390. elseif (str == "e") then
  391. ret = 14
  392. elseif (str == "f") then
  393. ret = 15
  394. elseif (str == "g") then
  395. ret = 16
  396. else
  397. ret = 0
  398. end
  399. return ret
  400. end
  401.  
  402. function debugPrint(str)
  403. if (debugFlag==1) then
  404. print(str)
  405. end
  406. end
  407.  
  408. -- Dervied from: http://www.computercraft.info/wiki/Excavate
  409. local function turnLeft()
  410. turtle.turnLeft()
  411. xDir, yDir = -yDir, xDir
  412. end
  413.  
  414. local function turnRight()
  415. turtle.turnRight()
  416. xDir, yDir = yDir, -xDir
  417. end
  418.  
  419. function goTo(x,y,z)
  420. goToFacing(x,y,z,xDir,yDir)
  421. end
  422.  
  423. function goToFacing( x, y, z, xd, yd )
  424. debugPrint("Starting at " .. xPos .. " " .. yPos .. " " .. zPos)
  425. debugPrint("Going to " .. x .. " " .. y .. " " .. z)
  426. -- This function moves on the z-axis first.
  427. while zPos > z do
  428. if turtle.down() then
  429. debugPrint("Went Down")
  430. zPos = zPos - 1
  431. else
  432. debugPrint("Can't go Down")
  433. sleep( 0.5 )
  434. end
  435. end
  436.  
  437. while zPos < z do
  438. if turtle.up() then
  439. debugPrint("Went Up")
  440. zPos = zPos + 1
  441. else
  442. debugPrint("Can't go Up")
  443. sleep( 0.5 )
  444. end
  445. end
  446.  
  447. if xPos > x then
  448. while xDir ~= -1 do
  449. if (xDir == 0 and yDir == -1) then
  450. debugPrint("Turning Right xPos > x")
  451. turnRight()
  452. else
  453. debugPrint("Turning Left xPos > x")
  454. turnLeft()
  455. end
  456. end
  457. while xPos > x do
  458. if turtle.forward() then
  459. debugPrint("Went Forward xPos > x")
  460. xPos = xPos - 1
  461. else
  462. debugPrint("Can't go Forward xPos > x")
  463. sleep( 0.5 )
  464. end
  465. end
  466. elseif xPos < x then
  467. while xDir ~= 1 do
  468. if (xDir == 0 and yDir == 1) then
  469. debugPrint("Turning Right xPos < x")
  470. turnRight()
  471. else
  472. debugPrint("Turning Left xPos < x")
  473. turnLeft()
  474. end
  475. end
  476. while xPos < x do
  477. if turtle.forward() then
  478. debugPrint("Went Forward xPos < x")
  479. xPos = xPos + 1
  480. else
  481. debugPrint("Can't go Forward xPos < x")
  482. sleep( 0.5 )
  483. end
  484. end
  485. end
  486.  
  487. if yPos > y then
  488. while yDir ~= -1 do
  489. if ( xDir == 1 and yDir == 0) then
  490. debugPrint("Turning Right yPos > y")
  491. turnRight()
  492. else
  493. debugPrint("Turning Left yPos > y")
  494. turnLeft()
  495. end
  496. end
  497. while yPos > y do
  498. if turtle.forward() then
  499. debugPrint("Went Forward yPos > y")
  500. yPos = yPos - 1
  501. else
  502. debugPrint("Can't go Forward yPos > y")
  503. sleep( 0.5 )
  504. end
  505. end
  506. elseif yPos < y then
  507. while yDir ~= 1 do
  508. if ( xDir == -1 and yDir == 0) then
  509. debugPrint("Turning Right yPos < y")
  510. turnRight()
  511. else
  512. debugPrint("Turning Left yPos < y")
  513. turnLeft()
  514. end
  515. end
  516. while yPos < y do
  517. if turtle.forward() then
  518. debugPrint("Went Forward yPos < y")
  519. yPos = yPos + 1
  520. else
  521. debugPrint("Can't go Forward yPos < y")
  522. sleep( 0.5 )
  523. end
  524. end
  525. end
  526.  
  527. while yDir ~= yd or xDir ~= xd do
  528. if (xd == yDir and yd == -xDir) then
  529. debugPrint("Returning Facing Right")
  530. turnRight()
  531. else
  532. debugPrint("Returning Facing Left")
  533. turnLeft()
  534. end
  535. end
  536. end
  537.  
  538. -- Refill the inventory from the chest
  539. function refill()
  540. --Refill fuel
  541. turtle.select(1)
  542. turtle.suckDown()
  543. turtle.suckDown()
  544. refuel()
  545. --Go to the specific chest to refill
  546. if (blockToPlace ~= 0) then
  547. goTo(blockToPlace + XHOME - 1,YHOME,ZHOME)
  548. turtle.select(blockToPlace)
  549. turtle.suckDown()
  550. turtle.suckDown()
  551. turtle.suckDown()
  552. turtle.suckDown()
  553. turtle.suckDown()
  554. turtle.suckDown()
  555. turtle.suckDown()
  556. turtle.suckDown()
  557. end
  558. end
  559.  
  560. function refuel()
  561. turtle.select(1)
  562. if(turtle.refuel(63)) then
  563. debugPrint("Refueled")
  564. else
  565. debugPrint("Could not Refuel")
  566. end
  567. fuel=turtle.getFuelLevel()
  568. debugPrint("Fuel is " .. fuel)
  569. end
  570.  
  571. function returnHome()
  572. -- Goes to 0,0 first.
  573. goTo(XHOME,YHOME,zPos)
  574. goTo(XHOME,YHOME,ZHOME)
  575. end
  576.  
  577. function returnHomeFacing01()
  578. -- Goes to 0,0 first.
  579. goTo(XHOME,YHOME,zPos)
  580. goToFacing(XHOME,YHOME,ZHOME,0,1)
  581. end
  582.  
  583. debugPrint("XSIZE, YSIZE, ZSIZE " .. table.getn(Array2d[1][1]) .. " " .. table.getn(Array2d[1]) .. " " .. ZSIZE)
  584. debugPrint("XSTRETCH, YSTRETCH, ZSTRETCH, " .. XSTRETCH .. " " .. YSTRETCH .. " " .. ZSTRETCH)
  585.  
  586. refill()
  587.  
  588. XSTRETCHSIZE=XSIZE*XSTRETCH
  589. YSTRETCHSIZE=YSIZE*YSTRETCH
  590. ZSTRETCHSIZE=ZSIZE*ZSTRETCH
  591.  
  592. if VERTFLIP == 1 then
  593. XSTRETCHSIZE = XSIZE*XSTRETCH
  594. YSTRETCHSIZE = ZSIZE*ZSTRETCH
  595. ZSTRETCHSIZE = YSIZE*YSTRETCH
  596. end
  597.  
  598. for zLoopIndex =1,ZSTRETCHSIZE do
  599. for yLoopIndex=1,YSTRETCHSIZE do
  600. for xLoopIndex=1,XSTRETCHSIZE do
  601.  
  602. if(slowMode==1) then
  603. sleep(2)
  604. end
  605.  
  606. xIdx= xLoopIndex
  607. yIdx= yLoopIndex
  608. zIdx= zLoopIndex
  609.  
  610. -- Weave back and forth
  611. if yIdx % 2 == 0 then
  612. xIdx = XSTRETCHSIZE + 1 - xIdx
  613. end
  614.  
  615. --FIXME
  616.  
  617. if VERTFLIP == 0 then
  618. xBlockIndex = math.ceil(xIdx/XSTRETCH)
  619. yBlockIndex = math.ceil((YSTRETCHSIZE + 1 - yIdx)/YSTRETCH) -- Keep in mind that y block index is opposite polarity of yIdx
  620. zBlockIndex = math.ceil(zIdx/ZSTRETCH)
  621. if (xBlockIndex > XSIZE or xBlockIndex < 1) then
  622. debugPrint("xBlockIndexError: " .. xBlockIndex)
  623. sleep(2)
  624. end
  625. if (yBlockIndex > YSIZE or yBlockIndex < 1) then
  626. debugPrint("yBlockIndexError: " .. yBlockIndex)
  627. sleep(2)
  628. end
  629. if (zBlockIndex > ZSIZE or zBlockIndex < 1) then
  630. debugPrint("zBlockIndexError: " .. zBlockIndex)
  631. sleep(2)
  632. end
  633. else
  634. xBlockIndex = math.ceil(xIdx/XSTRETCH)
  635. yBlockIndex = math.ceil((ZSTRETCHSIZE + 1 - zIdx)/ZSTRETCH)
  636. zBlockIndex = math.ceil(yIdx/YSTRETCH)
  637. if (xBlockIndex > XSIZE or xBlockIndex < 1) then
  638. debugPrint("xBlockIndexError: " .. xBlockIndex)
  639. sleep(2)
  640. end
  641. if (yBlockIndex > YSIZE or yBlockIndex < 1) then
  642. debugPrint("yBlockIndexError: " .. yBlockIndex)
  643. sleep(2)
  644. end
  645. if (zBlockIndex > ZSIZE or zBlockIndex < 1) then
  646. debugPrint("zBlockIndexError: " .. zBlockIndex)
  647. sleep(2)
  648. end
  649. end
  650.  
  651. debugPrint("BlockIndex Pre-Stretch: " .. xBlockIndex .. " " .. yBlockIndex .. " " .. zBlockIndex)
  652. if VERTFLIP == 0 then
  653. blockToPlace = convertString(Array2d[Array3d[zBlockIndex]][yBlockIndex][xBlockIndex]);
  654. else
  655. blockToPlace = convertString(Array2d[Array3d[zBlockIndex]][yBlockIndex][xBlockIndex]);
  656. end
  657. fuel=turtle.getFuelLevel()
  658. debugPrint("Prepare to Place " .. blockToPlace .. " at " .. xIdx .. " " .. yIdx .. " " .. " " .. zIdx)
  659.  
  660. -- If we don't have the material or are low on fuel, return home, refill, come back to the z-axis.
  661. if (blockToPlace ~= 0) then
  662. --If we still need to go refill, then go
  663. if (turtle.getItemCount(blockToPlace) < 2 or fuel < 500) then
  664. debugPrint("Returning Home")
  665. returnHome()
  666. debugPrint("Refilling")
  667. refill()
  668. end
  669.  
  670. if(blockOrientationMatters[blockToPlace]~=0) then
  671. -- Go to and face +y
  672. debugPrint("goToFacing " .. xIdx .. " " .. yIdx .. " " .. zIdx + 1 .. " - - 0 1")
  673. goToFacing( xIdx, yIdx, zIdx+1, 0, 1 )
  674. else
  675. -- Go to
  676. debugPrint("goTo " .. xIdx .. " " .. yIdx .. " " .. zIdx + 1)
  677. goTo( xIdx, yIdx, zIdx+1)
  678. end
  679. debugPrint("Select Block")
  680. turtle.select(blockToPlace)
  681.  
  682. flag = false
  683. while flag == false do
  684. if turtle.placeDown() then
  685. flag = true
  686. else
  687. debugPrint("Could not place block down")
  688. sleep (5)
  689. end
  690. end
  691. end
  692. end
  693. end
  694. end
  695. returnHomeFacing01()
  696. debugPrint("Done")
Add Comment
Please, Sign In to add comment