Advertisement
JMANN2400

ChestMiner

May 15th, 2020
1,238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. function destroy()
  2.     turtle.digDown()
  3.     turtle.dig()
  4.     turtle.digUp()
  5. end
  6.  
  7. function advance()
  8.     turtle.dig()
  9.     turtle.forward()
  10.     destroy()
  11.     turtle.forward()
  12.     destroy()
  13.     turtle.forward()
  14.     destroy()
  15.     turtle.back()
  16. end
  17.  
  18. function anyFullSlot()
  19.     for slotNum = 3, 16, 1 do
  20.         turtle.select(slotNum)
  21.         if (turtle.getItemSpace() == 0) then
  22.             return true
  23.         end
  24.     end
  25.     return false
  26. end
  27.  
  28. function depositItems()
  29.     turtle.digDown()
  30.     turtle.select(1)
  31.     turtle.placeDown()
  32.     for slotNum = 3, 16, 1 do
  33.         turtle.select(slotNum)
  34.         turtle.dropDown(turtle.getItemCount()-1)
  35.     end
  36. end
  37.  
  38. function hasChests()
  39.     return (turtle.getItemCount(1) > 0)
  40. end
  41.  
  42. print("+-------------------------------------+")
  43. print("| Chest Miner                         |")
  44. print("|    Slot 1: Chests                   |")
  45. print("|    Slot 2: Fuel                     |")
  46. print("|    Slot 3: Valuables                |")
  47. print("+-------------------------------------+")
  48. print("| Dig Height = ?                      |")
  49. print("+-------------------------------------+")
  50. h = tonumber(read())
  51.  
  52. while (hasChests()) do
  53.     advance()
  54.     for i = 0, h-3, 1 do
  55.         turtle.up()
  56.         destroy()
  57.     end
  58.     advance()
  59.     for i = 0, h-3, 1 do
  60.         turtle.down()
  61.         destroy()
  62.     end
  63.     if (turtle.getFuelLevel() < 80) then
  64.         turtle.select(2)
  65.         turtle.refuel(1)
  66.     end
  67.     if (anyFullSlot()) then
  68.         depositItems()
  69.     end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement