Advertisement
BigGamingGamers

Test

Nov 10th, 2020 (edited)
3,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. local SLOT_COUNT = 16
  2. local x, y, z, d = 0, 0, 0, "north"
  3. local width, depth, height = 10, 10, 2
  4.  
  5. if (#arg == 3) then
  6. width = tonumber(arg[1])
  7. depth = tonumber(arg[2])
  8. height = tonumber(arg[3])
  9. else
  10. print('None or Malformed Size Given, Defaulting to 10x10x2 up')
  11. end
  12.  
  13.  
  14. DROPPED_ITEMS = {
  15. "minecraft:stone",
  16. "minecraft:dirt",
  17. "minecraft:cobblestone",
  18. "minecraft:sand",
  19. "minecraft:gravel",
  20. "minecraft:redstone",
  21. "minecraft:flint",
  22. "railcraft:ore_metal",
  23. "extrautils2:ingredients",
  24. "minecraft:dye",
  25. "thaumcraft:nugget",
  26. "thaumcraft:crystal_essence",
  27. "thermalfoundation:material",
  28. "projectred-core:resource_item",
  29. "thaumcraft:ore_cinnabar",
  30. "deepresonance:resonating_ore",
  31. "forestry:apatite"
  32. }
  33. function dropItems()
  34. print("Purging Inventory...")
  35. for slot = 1, SLOT_COUNT, 1 do
  36. local item = turtle.getItemDetail(slot)
  37. if(item ~= nil) then
  38. for filterIndex = 1, #DROPPED_ITEMS, 1 do
  39. if(item["name"] == DROPPED_ITEMS[filterIndex]) then
  40. print("Dropping - " .. item["name"])
  41. turtle.select(slot)
  42. turtle.dropDown()
  43. end
  44. end
  45. end
  46. end
  47. end
  48.  
  49.  
  50. function getEnderIndex()
  51. for slot = 1, SLOT_COUNT, 1 do
  52. local item = turtle.getItemDetail(slot)
  53. if(item ~= nil) then
  54. if(item["name"] == "enderstorage:ender_storage") then
  55. return slot
  56. end
  57. end
  58. end
  59. return nil
  60. end
  61.  
  62. function manageInventory()
  63. dropItems()
  64. index = getEnderIndex()
  65. if(index ~= nil) then
  66. turtle.select(index)
  67. turtle.digUp()
  68. turtle.placeUp()
  69. end
  70. -- Chest is now deployed
  71. for slot = 1, SLOT_COUNT, 1 do
  72. local item = turtle.getItemDetail(slot)
  73. if(item ~= nil) then
  74. if(item["name"] ~= "minecraft:coal_block" and item["name"] ~= "minecraft:coal") then
  75. turtle.select(slot)
  76. turtle.dropUp()
  77. end
  78. end
  79. end
  80. -- Items are now stored
  81.  
  82. turtle.digUp()
  83. end
  84.  
  85. function checkFuel()
  86. turtle.select(1)
  87.  
  88. if(turtle.getFuelLevel() < 50) then
  89. print("Attempting Refuel...")
  90. for slot = 1, SLOT_COUNT, 1 do
  91. turtle.select(slot)
  92. if(turtle.refuel(1)) then
  93. return true
  94. end
  95. end
  96.  
  97. return false
  98. else
  99. return true
  100. end
  101. end
  102.  
  103. function trackPosition()
  104. if(d == "north") then
  105. z = z - 1
  106. end
  107. if(d == "east") then
  108. x = x + 1
  109. end
  110. if(d == "south") then
  111. z = z + 1
  112. end
  113. if(d == "west") then
  114. x = x - 1
  115. end
  116. end
  117.  
  118. function detectAndDig()
  119. while(turtle.detect()) do
  120. turtle.dig()
  121. end
  122. end
  123.  
  124. function forward()
  125. detectAndDig()
  126. turtle.forward()
  127. trackPosition()
  128. end
  129.  
  130. function leftTurn()
  131. turtle.turnLeft()
  132. detectAndDig()
  133. turtle.forward()
  134. turtle.turnLeft()
  135. end
  136.  
  137.  
  138. function rightTurn()
  139. turtle.turnRight()
  140. detectAndDig()
  141. turtle.forward()
  142. turtle.turnRight()
  143. end
  144.  
  145. function flipDirection()
  146. if(d == "north") then
  147. d = "south"
  148. elseif(d == "south") then
  149. d = "north"
  150. elseif(d == "west") then
  151. d = "east"
  152. elseif(d == "east") then
  153. d = "west"
  154. end
  155.  
  156. end
  157.  
  158. function turnAround(tier)
  159. if(tier % 2 == 1) then
  160. if(d == "north" or d == "east") then
  161. rightTurn()
  162. elseif(d == "south" or d == "west") then
  163. leftTurn()
  164. end
  165. else
  166. if(d == "north" or d == "east") then
  167. leftTurn()
  168. elseif(d == "south" or d == "west") then
  169. rightTurn()
  170. end
  171. end
  172. flipDirection()
  173. end
  174.  
  175.  
  176. function riseTier()
  177. turtle.turnRight()
  178. turtle.turnRight()
  179. flipDirection()
  180. turtle.digUp()
  181. turtle.up()
  182.  
  183. end
  184.  
  185.  
  186. function start()
  187. for tier = 1, height, 1 do
  188. for col = 1, width, 1 do
  189. for row = 1, depth - 1, 1 do
  190. if(not checkFuel()) then
  191. print("Turtle is out of fuel, Powering Down...")
  192. return
  193. end
  194. forward()
  195. print(string.format("Row: %d Col: %d", row, col))
  196. end
  197. if(col ~= width) then
  198. turnAround(tier)
  199. end
  200. manageInventory()
  201. end
  202. riseTier()
  203. end
  204. end
  205.  
  206. start()
  207.  
  208.  
  209.  
  210.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement