Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs ~= 1 then print ("Tunnel <profondeur>") return end
- local lenght = tonumber( tArgs[1] )
- if lenght <1 then print("la profondeur soir être un nombre psotif") return end
- local function rotate90(str)
- if type(str) ~= "string" then print("Invalide str") return end
- if str == "R" then
- turtle.turnRight()
- turtle.turnRight()
- elseif str == "L" then
- turtle.turnLeft()
- turtle.turnLeft()
- else
- error("Mauvaise direction")
- end
- end
- local function minigL(str)
- if turtle.turnLeft() then
- turtle.dig(str)
- rotate90("L")
- if turtle.detect() then
- turtle.dig(str)
- turtle.turnLeft()
- end
- end
- end
- local function oil()
- if turtle.getFuelLevel() < turtle.getFuelLimit() then
- turtle.refuel()
- end
- end
- local function try_dig(str) ---On prend la position
- if type(str) ~= "string" then print("Invalide str") return end
- if str == "D" then
- while turtle.detectDown() do
- if turtle.digDown() then
- sleep(0.5)
- else
- return false
- end
- end
- elseif str == "U" then
- while turtle.detectUp() do
- if turtle.digUp() then
- sleep(0.5)
- else
- return false
- end
- end
- elseif str == "F" then
- while turtle.detect() do
- if turtle.dig() then
- sleep(0.5)
- else
- return false
- end
- end
- else
- error("Erreur")
- end
- return true
- end
- local function try_UpDown(str)
- if type(str) ~= "string" then print("Invalide str") return end
- oil()
- if str == "D" then
- while not(turtle.down()) do
- if turtle.detectDown() then
- if not(try_dig(str)) then
- return false
- end
- else
- sleep(0.5)
- end
- end
- return true
- elseif str == "U" then
- while not(turtle.up()) do
- if turtle.detectUp() then
- if not(try_dig(str)) then
- return false
- end
- else
- sleep(0.5)
- end
- end
- return true
- elseif str == "F" then
- while not(turtle.forward()) do
- if turtle.detect() then
- if not(try_dig(str)) then
- return false
- end
- else
- sleep(0.5)
- end
- end
- return true
- else
- error("Erreur")
- end
- end
- for i=1, lenght, 1 do
- try_dig("U")
- turtle.turnLeft()
- try_dig("F")
- try_UpDown("U")
- try_dig("F")
- rotate90("R")
- try_dig("F")
- try_UpDown("D")
- try_dig("F")
- turtle.turnLeft()
- if i<lenght then
- try_dig("F")
- if not(try_UpDown("F")) then
- print("nop")
- break
- else
- print("tunnel finie")
- end
- end
- end
Add Comment
Please, Sign In to add comment