Advertisement
Guest User

MineDownCurrent

a guest
Dec 7th, 2019
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. acceptableItems = {'minecraft:diamond','minecraft:coal','minecraft:iron_ore','minecraft:emerald','minecraft:gold_ore','draconicevolution:draconium_dust'}
  2. acceptableItemsLength = 6
  3. -- 1 breaks up, -1 breaks down
  4. function destroy (direction)
  5.     if direction == 1 then
  6.         turtle.digUp()
  7.         turtle.up()
  8.     elseif direction == -1 then
  9.         turtle.digDown()
  10.         turtle.down()
  11.     else
  12.         error('invalid direction')
  13.     end
  14.     turtle.dig()
  15.     turtle.turnLeft()
  16.     turtle.turnLeft()
  17.     turtle.dig()
  18.     turtle.turnLeft()
  19.     turtle.turnLeft()
  20. end
  21.  
  22. -- if coal slot (1) has more than one coal, use
  23. function refuel ()
  24.     if turtle.getItemCount(1) > 1 then
  25.         turtle.select(1)
  26.         turtle.refuel(turtle.getItemCount()-1)
  27.     end
  28. end
  29.  
  30. -- remove all items not in list
  31. function purge ()
  32.     for i=2,16 do
  33.         keep = false
  34.         for j=1,acceptableItemsLength do
  35.             if turtle.getItemDetail(i).name == acceptableItems[j] then
  36.                 keep = true
  37.             end
  38.         end
  39.         if not keep then
  40.             turtle.select(i)
  41.             turtle.drop(i)
  42.         end
  43.     end
  44. end
  45.  
  46. -- returns true if every slot is completely full
  47. function turtleInvFull ()
  48.     fullCount = 0; -- # of slots full
  49.     for i=2,16 do
  50.         if turtle.getItemSpace(i) == 0 then
  51.             fullCount = fullCount + 1;
  52.         end
  53.     end
  54.     return fullCount == 15;
  55. end
  56.  
  57.  
  58. while (turtle.getFuelLevel() > 0) and not turtleInvFull() do
  59.     -- mining down
  60.     repeat
  61.         success, data = turtle.inspectDown()
  62.         destroy(-1)
  63.         refuel()
  64.         purge()
  65.     until data.name == 'minecraft:bedrock'
  66.  
  67.     -- moves to new spot to mine up
  68.     for i=1,3 do
  69.         turtle.dig()
  70.         turtle.forward()
  71.     end
  72.    
  73.     -- end if turtle inv completely full
  74.     if turtleInvFull() then
  75.         break
  76.     end
  77.        
  78.     -- mining up
  79.     for i=2,70 do
  80.         destroy(1)
  81.         refuel()
  82.         purge()
  83.     end
  84.  
  85.     -- moves to new spot to mine down
  86.     for i=1,3 do
  87.         turtle.forward()
  88.         turtle.dig()
  89.     end
  90. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement