Advertisement
Guest User

ACMV2.lua

a guest
Apr 8th, 2020
240
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. placeCheckpoint()
  167.  
  168. end
  169.  
  170. end
  171.  
  172.  
  173.  
  174.  
  175. function testIfFull()
  176.  
  177. local counter = 0
  178.  
  179. for i= 1, 16 do
  180.  
  181. turtle.select(i)
  182. if turtle.getItemCount() > 0 then
  183. counter = counter + 1
  184. end
  185. end
  186.  
  187. if counter > 2 then
  188. return true
  189.  
  190. else
  191. return false
  192.  
  193. end
  194. end
  195.  
  196. function returnToCenter()
  197.  
  198. for i = 1, circlesDone do
  199. toNextCheckpoint()
  200. end
  201.  
  202. end
  203.  
  204. function returnToChest()
  205.  
  206. repeat
  207. up()
  208. success, block = turtle.inspect()
  209. until block.name == "minecraft:netherrack"
  210.  
  211. end
  212.  
  213. function returnToPlant()
  214.  
  215. repeat
  216. down()
  217. success, block = turtle.inspectDown()
  218. until block.name == "minecraft:netherrack"
  219.  
  220. end
  221.  
  222. function returnToWork()
  223.  
  224. for i = 1, circlesDone do
  225. toNextCheckpoint()
  226. end
  227.  
  228. end
  229.  
  230. function emptyInventorry()
  231.  
  232. returnToCenter()
  233.  
  234. turtle.turnRight()
  235. turtle.turnRight()
  236.  
  237. returnToChest()
  238. chestDropp()
  239.  
  240. returnToPlant()
  241.  
  242. returnToWork()
  243.  
  244. end
  245.  
  246. function dumpTrash()
  247.  
  248. for i = 1, 16 do
  249.  
  250.  
  251. turtle.select(i)
  252.  
  253. if turtle.getItemCount() > 0 then
  254. local item = turtle.getItemDetail()
  255.  
  256. for i = 1, #Trash do
  257. if item.name == Trash[i] then
  258. turtle.drop()
  259. end
  260. end
  261.  
  262. end
  263. end
  264. end
  265.  
  266.  
  267.  
  268.  
  269. function startUp()
  270.  
  271. for i = 1,4 do
  272. turtle.dig()
  273. turtle.place()
  274. turtle.turnRight()
  275. end
  276.  
  277. while hight > startHight do
  278.  
  279. turtle.digDown()
  280. down()
  281. hight = hight - 1
  282.  
  283. end
  284.  
  285. placeCheckpoint()
  286.  
  287. end
  288.  
  289. function doMainStrip()
  290.  
  291. for i=1,circlesDinstance do
  292. digForward()
  293. Ore()
  294. end
  295.  
  296. placeCheckpoint()
  297.  
  298. circlesDone = circlesDone + 1
  299.  
  300. turtle.turnRight()
  301.  
  302. dumpTrash()
  303.  
  304. end
  305.  
  306. function doStrip()
  307.  
  308. for i=1, circlesDinstance * circlesDone do
  309. digForward()
  310. Ore()
  311. end
  312.  
  313. turtle.turnRight()
  314. turtle.turnRight()
  315.  
  316. toNextCheckpoint()
  317.  
  318. dumpTrash()
  319.  
  320. end
  321.  
  322. function doModul()
  323.  
  324. doMainStrip()
  325. dumpTrash()
  326.  
  327. doStrip()
  328. dumpTrash()
  329.  
  330. if testIfFull() then
  331.  
  332. turtle.turnLeft()
  333. emptyInventorry()
  334. turtle.turnLeft()
  335.  
  336. end
  337.  
  338. doStrip()
  339. dumpTrash()
  340.  
  341. if testIfFull() then
  342.  
  343. turtle.turnRight()
  344. emptyInventorry()
  345.  
  346. else
  347.  
  348. turtle.turnLeft()
  349.  
  350. end
  351.  
  352. end
  353.  
  354. function doSection()
  355.  
  356. for i = 1, circles do
  357.  
  358. doModul()
  359.  
  360. end
  361.  
  362. turtle.turnRight()
  363. turtle.turnRight()
  364.  
  365. returnToCenter()
  366.  
  367. circlesDone = 0
  368.  
  369. end
  370.  
  371. function doPlant()
  372.  
  373. for i = 1, 4 do
  374.  
  375. doSection()
  376.  
  377. turtle.turnRight()
  378.  
  379. end
  380.  
  381. toNextPlant()
  382.  
  383. end
  384.  
  385.  
  386.  
  387. function fuel()
  388. if turtle.getFuelLevel() < 7000 then
  389. turtle.refuel()
  390. end
  391. end
  392.  
  393. function chestDropp()
  394. for i=2,16 do
  395. turtle.select(i)
  396. fuel()
  397. turtle.dropUp()
  398. end
  399. end
  400.  
  401. startUp()
  402.  
  403. while true do
  404.  
  405. doPlant()
  406.  
  407. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement