Advertisement
Guest User

Untitled

a guest
Sep 24th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.87 KB | None | 0 0
  1. baseBlocks = {1, 2, 3, 4, 5, 6, 7, 8};
  2. stairs = { 9, 10, 11, 12 };
  3. slabs = {13, 14, 15};
  4. --not using fuel w/e
  5. fuel = { 16 };
  6. --[[
  7. columns defines a basic schematic of the wall; in this three dimensional array, every row is defined by five blocks and a column is seventeen blocks.
  8. block = 1, stair forward = 2, stair left = 3, stair right = 4, stair backward = 5, slab = 6
  9. --]]
  10. column = {
  11. {
  12. {0, 0, 4, 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, 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, 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, 0, 0}, {0, 0, 0, 0, 0}
  13. },
  14. {
  15. {6, 2, 1, 5, 6}, {0, 0, 1, 0, 0}, {0, 0, 4, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 3, 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 1, 0, 0} , {0, 2, 1, 5, 0} , {1, 6, 1, 6, 1}, {1, 1, 1, 1, 1}, {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}, {0, 0, 0, 0, 0}
  16. },
  17. {
  18. {1, 1, 0, 1, 1}, {3, 1, 0, 1, 3}, {0, 1, 0, 1, 0}, {0, 1, 1, 1, 0}, {0, 1,1,1, 0}, {0, 1,1,1, 0}, {0, 1, 0, 1, 0}, {0, 1, 0, 1, 0}, {1, 1, 0, 1, 1}, {1, 1, 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 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 1, 0, 0} , {0, 2, 1,5, 0} , {1, 6, 1, 6, 1}, {1, 1, 1, 1, 1}, {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}, {0, 0, 0, 0, 0}
  31. },
  32. {
  33. {0, 0, 3, 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, 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, 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, 0, 0}, {0, 0, 0, 0, 0}
  34. }
  35. }
  36.  
  37. --[[
  38. Checks if the user has enough resources, if not, then it will try to relocate the items to the designated slots.
  39. --]]
  40.  
  41. function checkResource(itemSlotRange, targetSlot )
  42. if turtle.getItemCount(targetSlot) == 0 then
  43. for i, item in ipairs(itemSlotRange) do
  44. if turtle.getItemCount(item) ~= 0 then
  45. turtle.select(item);
  46. turtle.transferTo(targetSlot);
  47. return;
  48. end
  49. end
  50. waitForResources();
  51. end
  52. end
  53.  
  54.  
  55. --[[
  56. Makes sure the wall starts at ground level - might not be wanted by some users; if you are that user there are two options:
  57. 1. place a block at the level you wish to make the wall (every 5 blocks if you are going to loop it)
  58. 2. remove the ensureZeroAltitude call (not this method) around the end of this file
  59. --]]
  60. function ensureZeroAltitude()
  61. refuel();
  62. while turtle.detectDown() == false do
  63. turtle.down();
  64. end
  65. end
  66.  
  67. function refuel()
  68. if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 80 then
  69. turtle.select(fuel[1])
  70. if turtle.getItemCount(fuel[1]) == 0 then
  71. print("no fuel detected, TAKE THEIR OIL and supply the turtle with it. \n \n Press any key when you have supplied the turtle with additional pylons");
  72. read();
  73. refuel();
  74. end
  75. turtle.refuel(1)
  76. end
  77. end
  78.  
  79. function waitForResources()
  80. print("Insufficient resources to continue making America great!; Supply more minerals for the cause");
  81. print("Press 'Any Key' to continue");
  82. read();
  83. checkAllResources();
  84. end
  85.  
  86. function checkAllResources()
  87. checkResource(baseBlocks, 1);
  88. checkResource(stairs, 9);
  89. checkResource(slabs, 14);
  90. refuel();
  91.  
  92. end
  93.  
  94. --[[
  95. Max time complexity algorithm; based on given width, height and length it will visit every possible location... but it works!
  96. --]]
  97. function walkPathTest(width, height, length)
  98. for k = 1, width do
  99. for j = 1, height do
  100. turtle.up();
  101. for i = 1, length do
  102. checkAllResources()
  103. placeBlock(column[k][j][i]);
  104. if i < length then
  105. turtle.forward()
  106. end
  107. end
  108. turnHundredeighty();
  109. end
  110. moveLeft();
  111. for i =1, length do
  112. if i < length then
  113. turtle.forward();
  114. end
  115. end
  116. for i = 1, height do
  117. turtle.down();
  118. end
  119. turnHundredeighty()
  120. end
  121. goToStart(length, width)
  122. walkPathTest(8, 17, 5);
  123. end
  124.  
  125. --[[
  126. Ensures that when you have ended the loop you start at the beginning of the new wall
  127. --]]
  128. function goToStart(length, width)
  129. for i = 1, length do
  130. turtle.forward();
  131. end
  132. turtle.turnLeft();
  133. for i = 1, width do
  134. turtle.forward();
  135. end
  136. turtle.turnRight();
  137. end
  138.  
  139.  
  140. function turnHundredeighty()
  141. for i = 1, 2 do
  142. turtle.turnLeft();
  143. end
  144. end
  145.  
  146. function moveLeft()
  147. turtle.turnLeft();
  148. turtle.forward();
  149. turtle.turnRight();
  150. end
  151.  
  152. function placeCommonBlock()
  153. turtle.select(1);
  154. turtle.placeDown();
  155. end
  156.  
  157. function placeSlab()
  158. turtle.select(14);
  159. turtle.placeDown();
  160. end
  161.  
  162.  
  163. --[[
  164. based on the given direction, it will perform a certain action. For instance at 2 it will place a block and at 3 it will place a stairs to the left.
  165. --]]
  166. function placeBlock(direction)
  167. if direction == 1 then
  168. placeCommonBlock();
  169. end
  170.  
  171. if direction == 2 then
  172. turtle.select(9);
  173. turtle.placeDown();
  174. end
  175. if direction == 3 then
  176. turtle.select(9)
  177. turtle.turnLeft();
  178. turtle.placeDown();
  179. turtle.turnRight();
  180. end
  181.  
  182. if direction == 4 then
  183. turtle.select(9)
  184. turtle.turnRight();
  185. turtle.placeDown();
  186. turtle.turnLeft();
  187. end
  188. if direction == 5 then
  189. turtle.select(9)
  190. turtle.turnLeft();
  191. turtle.turnLeft();
  192. turtle.placeDown();
  193. turtle.turnLeft();
  194. turtle.turnLeft();
  195. end
  196. if direction == 6 then
  197. placeSlab();
  198. end
  199. end
  200.  
  201. walkPathTest(8, 17, 5);
  202. ensureZeroAltitude();
  203. walkingForever();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement