Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x,y,z = ...
- x,y,z = tonumber(x), tonumber(y), tonumber(z)
- --better forward
- local function forward()
- while not turtle.forward() do
- turtle.dig()
- turtle.attack()
- end
- end
- --better up
- local function up()
- while not turtle.up() do
- turtle.digUp()
- turtle.attackUp()
- end
- end
- --main function to dig everything out
- local function dig_out()
- local height = 1
- local opposite = false
- forward()
- turtle.turnRight()
- --doing everything per layer
- for j = 1, z do
- --mining out per height
- for i = 1, y do
- --mining out each horizontal layer
- for i = 1, x - 1 do
- --height checks to speed up process by digging up/down
- if height == 1 then
- while turtle.detectUp() do
- turtle.digUp()
- end
- elseif height == y then
- while turtle.detectDown() do
- turtle.digDown()
- end
- else
- while turtle.detectUp() do
- turtle.digUp()
- end
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- forward()
- if height == 1 then
- while turtle.detectUp() do
- turtle.digUp()
- end
- elseif height == y then
- while turtle.detectDown() do
- turtle.digDown()
- end
- else
- while turtle.detectUp() do
- turtle.digUp()
- end
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- end
- if not opposite then opposite = true else opposite = false end
- if height == y then
- if opposite then
- turtle.turnRight()
- turtle.turnRight()
- for i = 1, x - 1 do
- forward()
- end
- turtle.turnRight()
- else
- turtle.turnRight()
- end
- for i = 1, y - 1 do
- turtle.digDown()
- turtle.down()
- end
- if j ~= z then
- forward()
- turtle.turnRight()
- end
- height = 1
- opposite = false
- break
- end
- --turning around
- turtle.turnRight()
- turtle.turnRight()
- -- going up
- for i = 1, 3 do
- if height == y then break end
- up()
- height = height + 1
- end
- end
- end
- end
- local function smart_fuel()
- local fuel_needed = (z + (z * (math.floor(y/3) * x))) * 1.4
- term.clear()
- if turtle.getFuelLevel() <= fuel_needed then
- while turtle.getFuelLevel() <= fuel_needed do
- term.clear()
- term.setCursorPos(1,1)
- print("Fuel needed:", fuel_needed)
- term.setCursorPos(1,2)
- print("Current fuel:", turtle.getFuelLevel())
- turtle.refuel()
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Success, beginning to dig.")
- end
- smart_fuel()
- dig_out()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement