Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local height = 4
- local depth = 64
- local torchSpace = 8
- -- Fonction de mouvement
- function UP()
- while (turtle.detect()) do
- turtle.dig()
- os.sleep(0.5)
- end
- while (turtle.detectUp()) do
- turtle.digUp()
- os.sleep(0.5)
- end
- turtle.up()
- end
- function TURN()
- while (turtle.detect()) do
- turtle.dig()
- os.sleep(0.5)
- end
- turtle.turnRight()
- turtle.turnRight()
- while (turtle.detect()) do
- turtle.dig()
- os.sleep(0.5)
- end
- end
- function DOWN()
- turtle.down()
- while (turtle.detect()) do
- turtle.dig()
- os.sleep(0.5)
- end
- end
- function FORWARD()
- while (turtle.detect()) do
- turtle.dig()
- os.sleep(0.5)
- end
- while (not turtle.forward()) do
- turtle.dig()
- os.sleep(0.5)
- end
- end
- -- Rechargement
- function REFUEL()
- turtle.select(1)
- if (turtle.refuel(1)) then
- return true
- else
- for i=2, 16 do
- turtle.select(i)
- if (turtle.refuel(1)) then
- return true
- end
- end
- end
- return false
- end
- function TORCH()
- for i=0, 1 do turtle.turnLeft() end
- turtle.select(2)
- turtle.place()
- for i=0, 1 do turtle.turnRight() end
- end
- -- Séquence principale
- function STEP(advencement)
- turtle.turnLeft()
- -- Montée
- for i=1, height-1 do
- UP()
- end
- -- Retournement
- TURN()
- -- Descente
- for i=1, height-1 do
- DOWN()
- end
- turtle.turnLeft()
- -- Avancement
- if (advencement > 1) then
- FORWARD()
- end
- -- Torches
- if (advencement % torchSpace == 0) then
- TORCH()
- end
- end
- -- Boucle principale
- for i=depth, 1, -1 do
- if (turtle.getFuelLevel() < (height*height)-1) then
- if REFUEL() then
- STEP(i)
- else
- os.sleep(20)
- i = i + 1
- print("Waiting for fuel")
- end
- else
- STEP(i)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement