Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function farm_avanti()
- --print('Avanti')
- for i = 0, 9 do
- turtle.forward()
- local successo, data = turtle.inspectDown()
- if successo then
- if data.state.age == 7 then
- turtle.digDown()
- turtle.placeDown()
- end
- elseif turtle.placeDown() then
- end
- end
- end
- local function gira_sx()
- --print('Gira Sinistra')
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- local function gira_dx()
- --print('Gira Destra')
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- local function torna_base()
- --print('Torna alla base')
- for i = 1, 10 do
- turtle.forward()
- end
- turtle.turnLeft()
- for i = 1, 9 do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- -- Funzione che controlla se l'inventario della turtle è pieno
- function inventarioPieno()
- for slot = 1, 16 do
- if turtle.getItemCount(slot) == 0 then
- return false -- C'è almeno uno slot vuoto
- end
- end
- return true -- Tutti gli slot sono pieni
- end
- local function gestione_inventario()
- -- Svuota e ricarica le patate
- for slot = 1, 16 do
- turtle.select(slot)
- turtle.dropDown()
- end
- turtle.select(1)
- turtle.suckDown(64)
- end
- local function gestione_carburante()
- -- Da implementrare
- end
- ---------------------------------------
- -- Programma turtle coltivazione v.2 --
- ---------------------------------------
- print("Farm automatica Patate")
- while true do
- gestione_inventario()
- if inventarioPieno() then
- print('Sia la cassa che la Turtle sono piene, fare spazio per riprendere la raccolta')
- print('Turtle in attesa...')
- else
- for i = 1, 9 do
- --print('i:'..i)
- if (i%2) == 1 then
- farm_avanti()
- gira_sx()
- else
- farm_avanti()
- gira_dx()
- end
- end
- torna_base()
- print('Finito un ciclo di Raccolta, in attesa di ricrescita prima di iniziare il successivo')
- end
- sleep(60)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement