Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Tamaño del área a minar
- local width = 25
- local length = 25
- local height = 3
- local progressFile = "progress.txt"
- -- Obtener progreso guardado
- function loadProgress()
- if fs.exists(progressFile) then
- local file = fs.open(progressFile, "r")
- local data = textutils.unserialize(file.readAll())
- file.close()
- return data.x, data.z
- end
- return 1, 1
- end
- -- Guardar progreso actual
- function saveProgress(x, z)
- local file = fs.open(progressFile, "w")
- file.write(textutils.serialize({x = x, z = z}))
- file.close()
- end
- -- Verificar y recargar combustible si es necesario
- function checkFuel()
- while turtle.getFuelLevel() < 100 do
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- turtle.refuel()
- end
- end
- if turtle.getFuelLevel() < 100 then
- print("Pon carburante crack")
- os.sleep(10)
- end
- end
- end
- -- Minar la columna 3x1 (frente, arriba y abajo)
- function mineColumn()
- turtle.digDown()
- turtle.dig()
- turtle.digUp()
- end
- -- Mover hacia adelante asegurando cavado
- function smartForward()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- -- Volver al inicio de la fila siguiente (zigzag)
- function turnToNextRow(z)
- if z % 2 == 1 then
- turtle.turnRight()
- smartForward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- smartForward()
- turtle.turnLeft()
- end
- end
- -- Volver al inicio si se detuvo
- function returnToStart(x, z)
- local facingEast = (z % 2 == 1)
- if not facingEast then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- for i = 1, x - 1 do
- smartForward()
- end
- turtle.turnRight()
- for i = 1, z - 1 do
- smartForward()
- end
- turtle.turnLeft()
- end
- -- Main loop
- function mineArea()
- local startX, startZ = loadProgress()
- returnToStart(startX, startZ)
- for z = startZ, length do
- for x = startX, width do
- checkFuel()
- mineColumn()
- if x < width then
- smartForward()
- end
- saveProgress(x, z)
- end
- if z < length then
- turnToNextRow(z)
- end
- startX = 1 -- Para nuevas filas, empezar desde el inicio
- end
- print("Minería completada.")
- fs.delete(progressFile)
- end
- mineArea()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement