Feldherren

miner v1

May 4th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 1 then
  3.     print( "Usage: miner <distance>" )
  4.     return
  5. end
  6.  
  7. local maxDist = tonumber( tArgs[1] )
  8. if maxDist < 1 then
  9.     print( "Distance must be positive" )
  10.     return
  11. end
  12.  
  13. local function find(itemName)
  14.     for curSlot = 1,16 do
  15.         local data = turtle.getItemDetail(curSlot)
  16.         if data.name == itemName then
  17.             return curSlot
  18.         end
  19.     end
  20.     return false
  21. end
  22.  
  23. local function digAround()
  24.     while turtle.detectUp() do
  25.         turtle.digUp()
  26.     end
  27.     if turtle.detectDown() then
  28.         local success, data = turtle.inspectDown()
  29.         if success then
  30.             if not (data.name == "minecraft:cobblestone") and not (data.name == "minecraft:stone") and not (data.name == "minecraft:sand") and not (data.name == "minecraft:dirt") and not (data.name == "minecraft:gravel") and not (data.name == "chisel:marble2") and not (data.name == "chisel:limestone2") then
  31.                 turtle.digDown()
  32.             end
  33.         end
  34.        
  35.     end
  36.     turtle.select(find("minecraft:cobblestone"))
  37.     turtle.placeDown()
  38. end
  39.  
  40. local function checkFuel(level)
  41.     if turtle.getFuelLevel() <= level then
  42.         turtle.select(find("minecraft:coal"))
  43.         turtle.refuel(1)
  44.     end
  45. end
  46.  
  47. for curDist=0,maxDist do
  48.     checkFuel(10)
  49.     while turtle.detect() do
  50.         turtle.dig()
  51.         digAround()
  52.     end
  53.     turtle.turnLeft()
  54.     while turtle.detect() do
  55.         turtle.dig()
  56.     end
  57.     turtle.forward()
  58.     digAround()
  59.     turtle.turnRight()
  60.     turtle.turnRight()
  61.     turtle.forward()
  62.     while turtle.detect() do
  63.         turtle.dig()
  64.     end
  65.     turtle.forward()
  66.     digAround()
  67.     turtle.turnLeft()
  68.     turtle.turnLeft()
  69.     turtle.forward()
  70.     turtle.turnRight()
  71.     if curDist ~= maxDist then
  72.         turtle.forward()
  73.     end
  74. end
  75.  
  76. turtle.turnLeft()
  77. turtle.turnLeft()
  78. for curDist=0,maxDist do
  79.     turtle.forward()
  80.     while turtle.detect() do
  81.         turtle.dig()
  82.     end
  83. end
  84.  
  85. for curSlot = 1,16 do
  86.     turtle.select(curSlot)
  87.     turtle.drop()
  88. end
  89. turtle.turnLeft()
  90. turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment