Advertisement
Guest User

ACMV2.lua

a guest
Apr 8th, 2020
894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.09 KB | None | 0 0
  1. turtle.refuel()
  2.  
  3. local plantDistance = 4
  4. local circles = 0
  5. local circlesDone = 0
  6. local circlesDinstance = 4
  7. local startHight = 0
  8. local endHight = 0
  9. local chestHight = 0
  10. local hight = 0
  11.  
  12. print("Current Hight:")
  13. hight = tonumber(read())
  14. print("")
  15.  
  16. print("Start Hight:")
  17. startHight = tonumber(read())
  18. print("")
  19.  
  20. print("Circles:")
  21. circles = tonumber(read())
  22. print("")
  23.  
  24. local success, block = nil
  25.  
  26. local Ores = {
  27.   "minecraft:coal_ore",
  28.   "minecraft:iron_ore",
  29.   "minecraft:gold_ore",
  30.   "minecraft:diamond_ore",
  31.   "minecraft:lapis_ore",
  32.   "minecraft:lit_redstone_ore",
  33.   "minecraft:emerald_ore",
  34.   "thermalfoundation:ore",
  35.   "thermalfoundation:ore_fluid",
  36.   "ic2:resource",
  37.   "bigreactors:oreyellorite",
  38.   "appliedenergistics2:quartz_ore",
  39.   "appliedenergistics2:charged_quartz_ore",
  40.   "deepresonance:resonating_ore",
  41.   "draconicevolution:draconium_ore",
  42.   "thaumcraft:ore_cinnabar",
  43.   "thaumcraft:ore_amber",
  44.   "thaumcraft:ore_quartz",
  45.   "projectred-exploration:ore",
  46.   "forestry:resources",
  47.   "bigreactors:orebenitoite",
  48.   "bigreactors:oreanglesite",
  49.   "biomesoplenty:gem_ore",
  50.   "astralsorcery:blockcustomore",
  51.   "actuallyadditions:block_misc",
  52.   "minecraft:quartz_ore",
  53.   "rftools:dimensional_shard_ore",
  54.   "quark:biotite_ore",
  55.   "railcraft:ore_metal_poor",
  56.   "railcraft:ore_metal",
  57.   "railcraft:ore_magic",
  58.   "woot:stygianironore",
  59. }
  60.  
  61. local Trash = {"minecraft:cobblestone","minecraft:dirt","minecraft:stone","minecraft:gravel",}
  62.  
  63.  
  64.  
  65.  
  66. function forward()
  67. turtle.attack()
  68. turtle.forward()
  69. end
  70.  
  71. function up()
  72. turtle.attackUp()
  73. turtle.up()
  74. end
  75.  
  76. function down()
  77. turtle.attackDown()
  78. turtle.down()
  79. end
  80.  
  81. function digForward()
  82.  
  83. while turtle.detect() do
  84. turtle.dig()
  85. end
  86. forward()
  87. end
  88.  
  89.  
  90.  
  91.  
  92.  
  93. function Ore()
  94.  
  95. success, block = turtle.inspectUp()
  96. for i=1,#Ores do
  97. if Ores[i] == block.name then
  98. block = nil
  99. turtle.digUp()
  100. up()
  101. Ore()
  102. down()
  103. break
  104. end
  105. end
  106.  
  107. for i=1,4 do
  108.  
  109. success, block = turtle.inspect()
  110. for i=1,#Ores do
  111. if Ores[i] == block.name then
  112. block = nil
  113. while turtle.detect() do
  114. turtle.dig()
  115. end
  116. forward()
  117. Ore()
  118. turtle.turnRight()
  119. turtle.turnRight()
  120. forward()
  121. turtle.turnRight()
  122. turtle.turnRight()
  123. break
  124. end
  125. end
  126.  
  127. turtle.turnRight()
  128.  
  129. end
  130.  
  131. success, block = turtle.inspectDown()
  132. for i=1,#Ores do
  133. if Ores[i] == block.name then
  134. block = nil
  135. turtle.digDown()
  136. down()
  137. Ore()
  138. up()
  139. break
  140. end
  141. end
  142.  
  143. end
  144.  
  145.  
  146.  
  147.  
  148. function placeCheckpoint()
  149. turtle.digDown()
  150. turtle.select(1)
  151. turtle.placeDown()
  152. end
  153.  
  154. function toNextCheckpoint()
  155. repeat
  156. forward()
  157. success, block = turtle.inspectDown()
  158. until block.name == "minecraft:netherrack"
  159. end
  160.  
  161. function toNextPlant()
  162.  
  163. for i = 1, plantDistance do
  164.  
  165. up()
  166.  
  167. end
  168.  
  169. placeCheckpoint()
  170.  
  171. end
  172.  
  173.  
  174.  
  175.  
  176. function testIfFull()
  177.  
  178. local counter = 0
  179.  
  180. for i= 1, 16 do
  181.  
  182. turtle.select(i)
  183. if turtle.getItemCount() > 0 then
  184. counter = counter + 1
  185. end
  186. end
  187.  
  188. if counter > 12 then
  189. return true
  190.  
  191. else
  192. return false
  193.  
  194. end
  195. end
  196.  
  197. function returnToCenter()
  198.  
  199. for i = 1, circlesDone do
  200. toNextCheckpoint()
  201. end
  202.  
  203. end
  204.  
  205. function returnToChest()
  206.  
  207. repeat
  208. up()
  209. success, block = turtle.inspect()
  210. until block.name == "minecraft:netherrack"
  211.  
  212. end
  213.  
  214. function returnToPlant()
  215.  
  216. repeat
  217. down()
  218. success, block = turtle.inspectDown()
  219. until block.name == "minecraft:netherrack"
  220.  
  221. end
  222.  
  223. function returnToWork()
  224.  
  225. for i = 1, circlesDone do
  226. toNextCheckpoint()
  227. end
  228.  
  229. end
  230.  
  231. function emptyInventorry()
  232.  
  233. returnToCenter()
  234.  
  235. turtle.turnRight()
  236. turtle.turnRight()
  237.  
  238. returnToChest()
  239. chestDropp()
  240.  
  241. returnToPlant()
  242.  
  243. returnToWork()
  244.  
  245. end
  246.  
  247. function dumpTrash()
  248.  
  249. for i = 1, 16 do
  250.  
  251.  
  252. turtle.select(i)
  253.  
  254. if turtle.getItemCount() > 0 then
  255. local item = turtle.getItemDetail()
  256.  
  257. for i = 1, #Trash do
  258. if item.name == Trash[i] then
  259. turtle.drop()
  260. end
  261. end
  262.  
  263. end
  264. end
  265. end
  266.  
  267.  
  268.  
  269.  
  270. function startUp()
  271.  
  272. for i = 1,4 do
  273. turtle.dig()
  274. turtle.place()
  275. turtle.turnRight()
  276. end
  277.  
  278. while hight > startHight do
  279.  
  280. turtle.digDown()
  281. down()
  282. hight = hight - 1
  283.  
  284. end
  285.  
  286. placeCheckpoint()
  287.  
  288. end
  289.  
  290. function doMainStrip()
  291.  
  292. for i=1,circlesDinstance do
  293. digForward()
  294. Ore()
  295. end
  296.  
  297. placeCheckpoint()
  298.  
  299. circlesDone = circlesDone + 1
  300.  
  301. turtle.turnRight()
  302.  
  303. dumpTrash()
  304.  
  305. end
  306.  
  307. function doStrip()
  308.  
  309. for i=1, circlesDinstance * circlesDone do
  310. digForward()
  311. Ore()
  312. end
  313.  
  314. turtle.turnRight()
  315. turtle.turnRight()
  316.  
  317. toNextCheckpoint()
  318.  
  319. dumpTrash()
  320.  
  321. end
  322.  
  323. function doModul()
  324.  
  325. doMainStrip()
  326. dumpTrash()
  327.  
  328. doStrip()
  329. dumpTrash()
  330.  
  331. if testIfFull() then
  332.  
  333. turtle.turnLeft()
  334. emptyInventorry()
  335. turtle.turnLeft()
  336.  
  337. end
  338.  
  339. doStrip()
  340. dumpTrash()
  341.  
  342. if testIfFull() then
  343.  
  344. turtle.turnRight()
  345. emptyInventorry()
  346.  
  347. else
  348.  
  349. turtle.turnLeft()
  350.  
  351. end
  352.  
  353. end
  354.  
  355. function doSection()
  356.  
  357. for i = 1, circles do
  358.  
  359. doModul()
  360.  
  361. end
  362.  
  363. turtle.turnRight()
  364. turtle.turnRight()
  365.  
  366. returnToCenter()
  367.  
  368. circlesDone = 0
  369.  
  370. end
  371.  
  372. function doPlant()
  373.  
  374. for i = 1, 4 do
  375.  
  376. doSection()
  377.  
  378. turtle.turnRight()
  379.  
  380. end
  381.  
  382. toNextPlant()
  383.  
  384. end
  385.  
  386.  
  387.  
  388. function fuel()
  389. if turtle.getFuelLevel() < 7000 then
  390. turtle.refuel()
  391. end
  392. end
  393.  
  394. function chestDropp()
  395. for i=2,16 do
  396. turtle.select(i)
  397. fuel()
  398. turtle.dropUp()
  399. end
  400. end
  401.  
  402. startUp()
  403.  
  404. while true do
  405.  
  406. doPlant()
  407.  
  408. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement