Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x = 0
- local y = 0
- local enderchest = 14
- local charbon = 15
- local torche = 16
- local slot = 0
- local cycletorche = 0
- local xrecharge = -2
- local yrecharge = -2
- local savex = 0
- local savey = 0
- local saveo = 0
- local orientation = 0
- local nbtunnel = 0
- local lgtunnel = 0
- local validation = 0
- local avancement = 0
- local tunnelcourant = 0
- function choix()
- term.clear()
- term.setCursorPos(1,1)
- print("bonjour ami mineur")
- write("longueur tunnel desiree : ")
- lgtunnel = tonumber(read())
- write("nombre de tunnel desiree : ")
- nbtunnel = tonumber(read())
- print("longueur des tunnels choisi : "..(lgtunnel))
- print("nombres de couloirs choisi : "..(nbtunnel))
- print("es-ce correct ? oui = 1 non = 0")
- validation = tonumber(read())
- end
- function viragegauche()
- turtle.turnLeft()
- orientation = orientation - 1
- if orientation == -1 then
- orientation = 3
- end
- end
- function viragedroite()
- turtle.turnRight()
- orientation = orientation + 1
- if orientation == 4 then
- orientation = 0
- end
- end
- function forward()
- turtle.dig()
- vidage()
- turtle.forward()
- turtle.digUp()
- vidage()
- refuel()
- if orientation == 0 then
- x = x + 1
- elseif orientation == 1 then
- y = y + 1
- elseif orientation == 2 then
- x = x - 1
- elseif orientation == 3 then
- y = y - 1
- end
- end
- function forwardrecharge()
- turtle.dig()
- vidage()
- turtle.forward()
- vidage()
- refuel()
- if orientation == 0 then
- x = x + 1
- elseif orientation == 1 then
- y = y + 1
- elseif orientation == 2 then
- x = x - 1
- elseif orientation == 3 then
- y = y - 1
- end
- end
- function back()
- turtle.back()
- refuel()
- if orientation == 0 then
- x = x - 1
- elseif orientation == 1 then
- y = y - 1
- elseif orientation == 2 then
- x = x + 1
- elseif orientation == 3 then
- y = y + 1
- end
- end
- function recharge()
- savex = x
- savey = y
- saveo = orientation
- print("en cours de rechargement")
- while y ~= 0 do
- while orientation ~= 3 do
- viragedroite()
- end
- forward()
- if turtle.getFuelLevel() < 50 then
- turtle.select(charbon)
- turtle.refuel(2)
- turtle.select(1)
- end
- end
- while x ~= 0 do
- while orientation ~= 2 do
- viragegauche()
- end
- forwardrecharge()
- if turtle.getFuelLevel() < 50 then
- turtle.select(charbon)
- turtle.refuel(2)
- turtle.select(1)
- end
- end
- turtle.select(charbon)
- turtle.suckDown()
- viragedroite()
- turtle.forward()
- turtle.select(torche)
- turtle.suckDown()
- turtle.select(1)
- print("rechargement termine, retour au travail")
- while x ~= savex do
- while orientation ~= 0 do
- viragegauche()
- end
- forwardrecharge()
- end
- while y ~= savey do
- while orientation ~= 1 do
- viragedroite()
- end
- forwardrecharge()
- end
- while saveo ~= orientation do
- viragedroite()
- end
- savex = 0
- savey = 0
- saveo = 0
- end
- function torchage()
- if turtle.getItemCount(torche) == 1 then
- recharge()
- end
- cycletorche = cycletorche + 1
- if cycletorche == 10 then
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.back()
- turtle.select(torche)
- turtle.placeUp()
- turtle.select(1)
- cycletorche = 0
- end
- end
- function refuel()
- if turtle.getItemCount(charbon) <= 4 then
- recharge()
- end
- if turtle.getFuelLevel() <= 50 then
- turtle.select(charbon)
- turtle.refuel(2)
- turtle.select(1)
- end
- end
- function tunnel()
- while avancement ~= lgtunnel do
- forward()
- avancement = avancement + 1
- refuel()
- vidage()
- torchage()
- end
- avancement = 0
- sauttunnel()
- tunnelcourant = tunnelcourant + 1
- end
- function sauttunnel()
- if orientation == 2 then
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- viragegauche()
- forward()
- forward()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.back()
- turtle.select(torche)
- turtle.placeUp()
- turtle.select(1)
- forward()
- viragegauche()
- elseif orientation == 0 then
- viragedroite()
- forward()
- forward()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.back()
- turtle.select(torche)
- turtle.placeUp()
- turtle.select(1)
- forward()
- viragedroite()
- end
- end
- function happybot()
- turtle.up()
- turtle. turnLeft()
- turtle. turnLeft()
- turtle. turnLeft()
- turtle. turnLeft()
- turtle.turnRight()
- turtle.turnRight()
- turtle.turnRight()
- turtle.turnRight()
- turtle.down()
- end
- function retour()
- print("je vous emmerde, et je rentre a ma maison!! ")
- while x ~= 0 do
- while orientation ~= 2 do
- viragegauche()
- end
- forwardrecharge()
- if fuellevel < 50 then
- turtle.select(charbon)
- turtle.refuel(2)
- turtle.select(1)
- end
- end
- while y ~= 0 do
- while orientation ~= 3 do
- viragedroite()
- end
- forwardrecharge()
- end
- end
- function vidage()
- if turtle.getItemCount(13) > 0 then
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.back()
- turtle.select(enderchest)
- turtle.place()
- for slot=1,13 do
- turtle.select(slot)
- while turtle.getItemCount(slot) > 0 do
- turtle.drop(turtle.getItemCount(slot))
- if turtle.getItemCount(slot) > 0 then
- sleep(1)
- end
- end
- end
- end
- turtle.select(enderchest)
- turtle.dig()
- turtle.select(1)
- end
- while validation ~= 1 do
- choix()
- end
- term.clear()
- term.setCursorPos(1,1)
- print("tache aquise, travail en cours ")
- while tunnelcourant ~= nbtunnel do
- tunnel()
- end
- retour()
- happybot()
- print("travail termine")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement