Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- arriva fino al prossimo tronco e ci si ferma davanti.
- -- ritorna true se trova tronco o false se trova cancello
- passi = 0
- unloaded = 0
- tempo=0
- local function scarica()
- print( "Scaricando Oggetti..." )
- for n=3,16 do
- unloaded = unloaded + turtle.getItemCount(n)
- turtle.select(n)
- turtle.drop()
- end
- collected = 0
- turtle.select(1)
- end
- function prossimoTronco()
- -- selezione il recinto, se davanti c'åA8 un recinto, si torna indietro
- turtle.select(2)
- if turtle.compare() then return false end
- -- seleziona il tronco d'albero, ritorna vero se trova un albero
- while not turtle.compare() do
- turtle.forward()
- passi = passi + 1
- turtle.select(2)
- if turtle.compare() then return false end
- turtle.select(1)
- end
- return true
- end
- function cambiaLato()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- function succhiaGiu()
- while not turtle.detectDown() do
- turtle.down()
- turtle.dig()
- end
- end
- function tornaDavanti()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- passi = passi + 2
- end
- -- succhia ogni blocco di ogni lato del tronco poi gira davanti al tronco
- function succhiaSu()
- while turtle.compare() do
- turtle.dig()
- turtle.up()
- end
- end
- -- ritorna alla base e deposita la gomma
- function tornaIndietro()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- for i= 0, passi do
- turtle.forward()
- -- print ("passo # " .. i)
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- function succhiaAlbero()
- succhiaSu()
- cambiaLato()
- succhiaGiu()
- cambiaLato()
- succhiaSu()
- cambiaLato()
- succhiaGiu()
- tornaDavanti()
- end
- function tornaPosizione()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- vai = true
- while vai do
- passi = 0
- while prossimoTronco() do
- succhiaAlbero()
- end
- passi = passi + 1
- tornaIndietro()
- scarica()
- tornaPosizione()
- sleep(3600)
- end
Advertisement
Add Comment
Please, Sign In to add comment