Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function printUsage()
- print( "Usage:" )
- print( "minage <distance par shafts>" )
- end
- local function refuel()
- shell.run("refuel", "all")
- turtle.select(1)
- if turtle.getFuelLevel() == 0 then return false end
- end
- local function digforward()
- if turtle.getFuelLevel() > 0 then
- turtle.digUp()
- while turtle.detect() do turtle.dig() sleep(0.5) end
- while turtle.detectUp() do turtle.digUp() sleep(0.5) end
- local walked = turtle.forward()
- if not walked then
- print("ERREUR : Impossible d'avancer plus")
- if turtle.detect() then
- print("Il y a un bloc")
- digforward()
- if turtle.detectDown() == false then turtle.placeDown() end
- return true
- else
- print("ERREUR : Il doit y avoir un mob.")
- while true do
- turtle.attack()
- walked = turtle.forward()
- if turtle.detectDown() == false then turtle.placeDown() end
- if walked == true then break end
- end
- print("SUCCES : Mob disparu")
- return true
- end
- return false
- end
- if turtle.detectDown() == false then turtle.placeDown() end
- return true
- else
- print("Manque d'energie. Tentative de refuel.")
- if refuel() == false then
- print("ERREUR : Plus de fuel.")
- return false
- end
- end
- end
- local tArgs = { ... }
- if #tArgs == 0 then
- printUsage()
- return
- end
- local goal = tonumber(tArgs[1])-1
- turtle.select(2)
- while true do
- chemin = 0
- while chemin <= goal do
- if digforward() == false then return
- else
- chemin = chemin+1
- end
- end
- turtle.turnRight()
- turtle.turnRight()
- chemin = 0
- while chemin <= goal do
- if digforward() == false then return
- else
- chemin = chemin+1
- end
- end
- turtle.turnLeft()
- for i=0,3 do
- local walked = turtle.forward()
- if not walked then print("ERREUR : Fin du tunnel") return end
- end
- turtle.turnLeft()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement