Advertisement
ivanzrer

nether_V1

Sep 28th, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | Source Code | 0 0
  1. args = {...}
  2. distance = args[1]
  3.  
  4. function mine (direction)
  5.     --default harvest actionset
  6.     if direction = "up" then
  7.         turtle.digUp()
  8.         turtle.up()
  9.         scan()
  10.         turtle.down()
  11.     elseif direction = "down" then
  12.         turtle.digDown()
  13.         turtle.down()
  14.         scan()
  15.         turtle.up()
  16.     else
  17.         turtle.dig()
  18.         turtle.forward()
  19.         turtle.scan()
  20.     end
  21. end
  22.  
  23. function scan ()
  24.     --seach surrounding for desired block, and call mine() if found
  25.     turtle.select(1)
  26.     if turtle.compare() then
  27.         mine()
  28.     end
  29.     if turtle.compareUp() then
  30.         mine("up")
  31.     end
  32.     if turtle.compareDown() then
  33.         mine("down")
  34.     end
  35.     turtle.turnLeft()
  36.     if turtle.compare() then
  37.         mine()
  38.     end
  39.     turtle.turnRight()
  40.     turtle.turnRight()
  41.     if turtle.compare() then
  42.         mine()
  43.     end
  44.     turtle.turnLeft()
  45.  
  46. end
  47.  
  48. function movement (length)
  49.     --default moveset
  50.     for i=1, length,1 do
  51.         turtle.dig()
  52.         turtle.forward()
  53.         scan()
  54.     end
  55.     backtrack(length)
  56. end
  57.  
  58. function backtrack (distance)
  59.     --return to start
  60.     turtle.turnRight()
  61.     turtle.turnRight()
  62.     for i=1, length,1 do
  63.         turtle.forward()
  64.     end
  65. end
  66.  
  67. function mayne (length)
  68.     --main function
  69.  
  70.     --check for block, and refuel
  71.     turtle.select(1)
  72.     if turtle.getItemCount(1) = 0 then
  73.         turtle.print("No supplied block")
  74.         os.sleep(10)
  75.         os.exit()
  76.     elseif turtle.getItemCount(2) > 0 then
  77.         turtle.select(2)
  78.         if turtle.refuel(0) then
  79.             turtle.refuel()
  80.         else
  81.             print("no new fuel provided")
  82.         end
  83.     end
  84.     if turtle.getFuelLevel < (distance * 2) then
  85.         print("fuel level too low to complete desired distance")
  86.         os.sleep(10)
  87.         os.exit()
  88.     end
  89.     --begin search
  90.     movement(length)
  91.  
  92. end
  93.  
  94.  
  95.  
  96. if distance = "help" or "" then
  97.     print("usage: nether [desired mine length]")
  98.     print("halts if it hits an unloaded chunk, so keep within reason")
  99.     print("block to seach for in first slot, fuel in second")
  100. end
  101.  
  102. if not distance then
  103.     distance = 30
  104. end
  105.  
  106. mayne(distance)
  107.  
  108.  
  109.  
  110. --check for precence of block
  111. --refuel
  112. --mine
  113. --move forward
  114. --check surrounding blocks, and mine if debris
  115. --continue until length limit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement