Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NbBoucle = 1
- NbBloques = 50
- Direction = "Gauche"
- Direction2 = "Droite"
- dire = 0
- defaultmode = 1
- function Avance(Nb)
- nbDeplacement = 0
- jPrint = 0
- for i = 0, Nb do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- nbDeplacement = nbDeplacement + 1
- jPrint = jPrint + 1
- term.clear()
- print("Blocs : "..jPrint)
- while turtle.detectUp() do
- turtle.digUp()
- os.sleep(0.5)
- end
- if nbDeplacement == 10 then
- turtle.select(16)
- DeposeTorche()
- nbDeplacement = 0
- end
- end
- end
- function Tourne(Turn)
- if Turn == "Droite" then
- turtle.turnRight()
- end
- if Turn == "Gauche" then
- turtle.turnLeft()
- end
- end
- function DeposeTorche()
- turtle.back()
- Tourne("Gauche")
- if turtle.detect() then
- turtle.placeUp()
- end
- Tourne("Droite")
- turtle.forward()
- end
- print("Quel mode souhaitez vous lancer ?")
- print("0 default gauche, 1 default droite, 2 Full configure ")
- defaultmode = read()
- if defaultmode == "1" then
- Direction = "Droite"
- Direction2 = "Gauche"
- end
- if(defaultmode == "2") then
- term.clear()
- print("Combien d'aller-retour voulez-vous faire ?")
- NbBoucle = read()
- print("Combien de blocs ?")
- NbBloques = read()
- print("Quelle Direction 1/Gauche, 2/Droite?")
- dire = read()
- if dire == "1" then
- Direction = "Gauche"
- Direction2 = "Droite"
- end
- if dire == "2" then
- Direction = "Droite"
- Direction2 = "Gauche"
- end
- end
- for j = 1 , NbBoucle do
- print("Aller retour n "..j)
- Avance(NbBloques)
- Tourne(Direction)
- Avance(2)
- DeposeTorche()
- Tourne(Direction)
- Avance(NbBloques)
- Tourne(Direction2)
- Avance(2)
- Tourne(Direction2)
- end
- term.clear()
- print("Fuel restant : "..turtle.getFuelLevel())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement