Advertisement
Blazuno

Untitled

Dec 22nd, 2024 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.59 KB | None | 0 0
  1. local x,y,z = ...
  2. x,y,z = tonumber(x), tonumber(y), tonumber(z)
  3.  
  4. --better forward
  5. local function forward()
  6.     while not turtle.forward() do
  7.         turtle.dig()
  8.         turtle.attack()
  9.     end
  10. end
  11.  
  12. --better up
  13. local function up()
  14.     while not turtle.up() do
  15.         turtle.digUp()
  16.         turtle.attackUp()
  17.     end
  18. end
  19.  
  20. --main function to dig everything out
  21. local function dig_out()
  22.     local height = 1
  23.     local opposite = false
  24.     forward()
  25.     turtle.turnRight()
  26.     --doing everything per layer
  27.     for j = 1, z do
  28.         --mining out per height
  29.         for i = 1, y do
  30.             --mining out each horizontal layer
  31.             for i = 1, x - 1 do
  32.                 --height checks to speed up process by digging up/down
  33.                 if height == 1 then
  34.                     while turtle.detectUp() do
  35.                         turtle.digUp()
  36.                     end
  37.                 elseif height == y then
  38.                     while turtle.detectDown() do
  39.                         turtle.digDown()
  40.                     end
  41.                 else
  42.                     while turtle.detectUp() do
  43.                         turtle.digUp()
  44.                     end
  45.                     while turtle.detectDown() do
  46.                         turtle.digDown()
  47.                     end
  48.                 end
  49.                 forward()
  50.                 if height == 1 then
  51.                     while turtle.detectUp() do
  52.                         turtle.digUp()
  53.                     end
  54.                 elseif height == y then
  55.                     while turtle.detectDown() do
  56.                         turtle.digDown()
  57.                     end
  58.                 else
  59.                     while turtle.detectUp() do
  60.                         turtle.digUp()
  61.                     end
  62.                     while turtle.detectDown() do
  63.                         turtle.digDown()
  64.                     end
  65.                 end
  66.             end
  67.             if not opposite then opposite = true else opposite = false end
  68.             if height == y then
  69.                 if opposite then
  70.                     turtle.turnRight()
  71.                     turtle.turnRight()
  72.                     for i = 1, x - 1 do
  73.                         forward()
  74.                     end
  75.                     turtle.turnRight()
  76.                 else
  77.                     turtle.turnRight()
  78.                 end
  79.                 for i = 1, y - 1 do
  80.                     turtle.digDown()
  81.                     turtle.down()
  82.                 end
  83.                 if j ~= z then
  84.                     forward()
  85.                     turtle.turnRight()
  86.                 end
  87.                 height = 1
  88.                 opposite = false
  89.                 break
  90.             end
  91.             --turning around
  92.             turtle.turnRight()
  93.             turtle.turnRight()
  94.             -- going up
  95.             for i = 1, 3 do
  96.                 if height == y then break end
  97.                 up()
  98.                 height = height + 1
  99.             end
  100.         end
  101.     end  
  102. end
  103.  
  104. local function smart_fuel()
  105.     local fuel_needed = (z + (z * (math.floor(y/3) * x))) * 1.4
  106.     term.clear()
  107.     if turtle.getFuelLevel() <= fuel_needed then
  108.         while turtle.getFuelLevel() <= fuel_needed do
  109.             term.clear()
  110.             term.setCursorPos(1,1)
  111.             print("Fuel needed:", fuel_needed)
  112.             term.setCursorPos(1,2)
  113.             print("Current fuel:", turtle.getFuelLevel())
  114.             turtle.refuel()
  115.         end
  116.     end
  117.     term.clear()
  118.     term.setCursorPos(1,1)
  119.     print("Success, beginning to dig.")
  120. end
  121.  
  122. smart_fuel()
  123. dig_out()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement