Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Robot producteur de ressource botania
- -- Video : https://www.youtube.com/watch?v=LSnDyYUoZYI
- -- Function deplacement + refuel
- function deplace()
- info("Deplacement "..turtle.getFuelLevel())
- if turtle.getFuelLevel()==0 then
- turtle.select(16)
- turtle.refuel(1)
- end
- turtle.forward()
- end
- -- Verification si faut sortir du sommeil pour recolte
- -- false si recoltable ou vide
- -- true si non recoltable
- function verif()
- ok, donne = turtle.inspectDown()
- if ok then
- if donne.name=="Botania:livingrock" then
- return false
- elseif donne.name=="Botania:livingwood" then
- return false
- else
- return true
- end
- else
- perma=false
- return false
- end
- end
- -- Verification si block present en dessous
- function stop()
- ok, donne = turtle.inspectDown()
- if ok==false then
- return true
- else
- return false
- end
- end
- -- Attent et change le block en dessous
- function change()
- info("Attente")
- while verif() do
- os.sleep(3)
- end
- info("Minage / placement")
- turtle.select(2)
- turtle.digDown()
- turtle.select(1)
- turtle.placeDown()
- end
- -- Affichage info
- function info(text)
- term.clear()
- term.setCursorPos(1,1)
- print(text)
- end
- local perma=true
- -- function recolte
- function go()
- local pos=0
- local coin=0
- -- boucle temps que recoltable
- while perma do
- -- change le block
- change()
- -- avance
- deplace()
- -- verification position pour tourner dans les angle
- pos=pos+1
- if pos==2 then
- if coin==3 then
- -- point de depart
- info("Depart")
- turtle.turnLeft()
- -- pose de la recolte
- turtle.select(2)
- turtle.drop()
- -- stop si plus rien a recolter
- if stop() then
- return
- info("Fin")
- end
- -- chargement roche ou bois
- turtle.turnRight()
- charge()
- -- chargement charbon
- info("Charge charbon")
- if turtle.getItemCount(16) == 0 then
- turtle.select(16)
- turtle.suckUp()
- end
- -- positionnemetn
- turtle.turnRight()
- coin=0
- else
- turtle.turnRight()
- coin=coin+1
- end
- pos=0
- end
- end
- end
- -- fonction chargement roche - bois
- function charge()
- info("Charge obj")
- -- si moins de 8 on charge
- if turtle.getItemCount(1) < 8 then
- turtle.select(1)
- turtle.suck()
- qte=turtle.getItemCount(1)
- -- si toujours moins de 8 on drop dans le corffre
- if qte<8 then
- turtle.drop()
- end
- -- si trop de ressource on drop dans le coffre
- if turtle.getItemCount(2) ~= 0 then
- turtle.select(2)
- turtle.drop()
- end
- end
- end
- -- premier tour sans recolte, juste pose
- function premier()
- info("Depos ressource vide")
- local pos=0
- local coin=0
- local perma2=true
- turtle.select(1)
- -- boucle sur un tour
- while perma2 do
- turtle.placeDown()
- deplace()
- pos=pos+1
- if pos==2 then
- if coin==3 then
- -- si depart on stop pour passer en normal
- turtle.turnRight()
- perma2=false
- return
- else
- turtle.turnRight()
- coin=coin+1
- end
- pos=0
- end
- end
- end
- -- placement en fonction des deux cote vide
- info("Placement");
- ok=0
- while ok<2 do
- turtle.turnLeft()
- presence, donne = turtle.inspect()
- if presence then
- ok=0
- else
- ok=ok+1
- end
- end
- turtle.turnLeft()
- charge()
- turtle.turnRight()
- -- si pas vide on passee en normal
- ok, donne = turtle.inspectDown()
- if ok then
- go()
- else
- -- si vide on verifie les ressources et on fait une premier tour
- if turtle.getItemCount(1) == 0 then
- info("Pas de ressource")
- else
- premier()
- go()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement