Advertisement
Iepoev

netherborer

Nov 1st, 2020 (edited)
4,285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.90 KB | None | 0 0
  1. -- netherborer.lua
  2. -- gaat een 9 breed op 9 hoog tunnel graven, tot 256 blocks lang.
  3. -- zal iedere 8 blocks zijn inventory legen, door items in de blacklist te yeeten en de rest te storen in een chest
  4.  
  5. -- Primen door:
  6. -- 32 chests in slot 1
  7. -- een flint and steel in slot 2
  8. -- een empty bucket in slot 2
  9. -- plaats 1 item van de whitelisted resources in de inventory
  10. -- kies jouw 9x9 vlak en maak een gat in de linkeronderhoek op ooghoogte
  11. -- plaats de borer hierin, voorkant gericht op de richting van de tunnel
  12. -- execute het script
  13.  
  14.  
  15. -- HELPERS
  16. function contains(list, x)
  17.     for _, v in pairs(list) do
  18.         if v == x then return true end
  19.     end
  20.     return false
  21. end
  22.  
  23. function safeForward()
  24.     succ = turtle.forward()
  25.     while not succ do
  26.         turtle.dig()
  27.         succ = turtle.forward()
  28.     end
  29. end
  30.  
  31. function safeDig()
  32.     local bool, block = turtle.inspect()
  33.     if bool then
  34.         if block.name == "minecraft:lava" then
  35.             turtle.select(4)
  36.             turtle.place()
  37.             turtle.refuel()
  38.             turtle.select(1)
  39.         end
  40.         turtle.dig()
  41.     end
  42. end
  43.  
  44. function safeDigDown()
  45.     local bool, block = turtle.inspectDown()
  46.     if bool then
  47.         if block.name == "minecraft:lava" then
  48.             turtle.select(4)
  49.             turtle.placeDown()
  50.             turtle.refuel()
  51.             turtle.select(1)
  52.         end
  53.         turtle.digDown()
  54.     end
  55. end
  56.  
  57. function safeDigUp()
  58.     local bool, block = turtle.inspectUp()
  59.     if bool then
  60.         if block.name == "minecraft:lava" then
  61.             turtle.select(3)
  62.             turtle.placeUp()
  63.             turtle.refuel()
  64.             turtle.select(1)
  65.         end
  66.         turtle.digUp()
  67.     end
  68. end
  69.  
  70. -- GLOBALS
  71.  
  72. blacklist = {
  73.     "minecraft:basalt",
  74.     "minecraft:netherrack",
  75.     "minecraft:blackstone"
  76.     }
  77.  
  78. whitelist = {
  79.     "minecraft:magma_block",
  80.     "minecraft:quartz",
  81.     "minecraft:gold_nugget",
  82.     "minecraft:ancient_debris"
  83.     }
  84.  
  85. -- DIGGER
  86.  
  87. function digHorizontalSlice(sliceidx, onFloor)
  88.     for i=2,9 do -- horizontal slice
  89.         turtle.dig()
  90.         safeForward()
  91.         safeDigUp()
  92.         safeDigDown()
  93.     end
  94. end
  95.  
  96.  
  97. -- if torch is true, place a torch
  98. function goThreeUp()
  99.     turtle.up()
  100.     safeDigUp()
  101.     turtle.up()
  102.     safeDigUp()
  103.     turtle.up()
  104.     safeDigUp()
  105.     turtle.turnRight()
  106.     turtle.turnRight()
  107. end
  108.  
  109. function goThreeDown()
  110.     turtle.turnRight()
  111.     turtle.turnRight()
  112.     turtle.down()
  113.     safeDigDown()
  114.     turtle.down()
  115.     safeDigDown()
  116.     turtle.down()
  117.     safeDigDown()
  118. end
  119.  
  120. function digSlice(i)
  121.     turtle.turnRight()
  122.     safeDigUp()
  123.     safeDigDown()
  124.     digHorizontalSlice(i, true)
  125.     goThreeUp()
  126.     digHorizontalSlice(i, false)
  127.     goThreeUp()
  128.     digHorizontalSlice(i, false)
  129.  
  130.     turtle.turnLeft()
  131.     turtle.dig()
  132.     safeForward()
  133.     turtle.turnLeft()
  134.     safeDigUp()
  135.     safeDigDown()
  136.  
  137.     digHorizontalSlice(false)
  138.     goThreeDown()
  139.     digHorizontalSlice(false)
  140.     goThreeDown()
  141.     digHorizontalSlice(false)
  142. end
  143.  
  144. function digChunk()
  145.     for i=1,4 do
  146.         digSlice(i)
  147.         dumpBlacklist()
  148.         turtle.turnRight()
  149.         turtle.dig()
  150.         safeForward()
  151.         safeDigUp()
  152.         safeDigDown()
  153.     end
  154. end
  155.  
  156. -- INVENTORY
  157.  
  158. function dumpBlacklist()
  159.     turtle.select(2) -- fire
  160.     turtle.placeDown()
  161.     for i=7,16 do
  162.         turtle.select(i)
  163.         local item = turtle.getItemDetail()
  164.         if item ~= nil then
  165.             if contains(blacklist, item.name) then -- trash
  166.                 turtle.dropDown(item.count)
  167.             end
  168.         end
  169.     end
  170.     turtle.select(1)
  171. end
  172.  
  173. function clearInventory()
  174.     turtle.back()
  175.     turtle.select(1) -- chest
  176.     chestsuccess = turtle.placeUp()
  177.     turtle.select(2) -- fire
  178.     turtle.placeDown()
  179.     for i=4,16 do
  180.         turtle.select(i)
  181.         local item = turtle.getItemDetail()
  182.         if item ~= nil then
  183.             if item.name == "minecraft:coal" and turtle.getFuelLevel() < 1000 then --refuel
  184.                 turtle.refuel(item.count-1)
  185.             elseif contains(blacklist, item.name) then -- trash
  186.                 turtle.dropDown(item.count)
  187.             elseif contains(whitelist, item.name) and chestsuccess and i < 7 then -- keep 1 in inventory
  188.                 turtle.dropUp(item.count - 1)
  189.             elseif chestsuccess then
  190.                 turtle.dropUp(item.count) --store
  191.             end
  192.         end
  193.     end
  194.     turtle.select(1)
  195.     safeForward()
  196. end
  197.  
  198. -- MAIN
  199.  
  200. for i=1,32 do
  201.     digChunk()
  202.     clearInventory()
  203. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement