Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- carica un materiale dalla chest
- -- divide per nove e restituisce nella chest quello in eccesso
- -- posizione 9 mucchietti nell'inventario; craft; mette il risultato nella chest
- -- craft negli slot: 5,6,7,9,10,11,13,14,15
- craftingSlot = 13
- function getFromChest(pezzi)
- turtle.turnLeft()
- for i = 1, 5 do
- turtle.select(i)
- turtle.suck()
- end
- turtle.turnRight()
- end
- function prepareCrafting(usableSlot)
- -- divide in mucchi multipli di 9
- turtle.select(usableSlot)
- pezzi = turtle.getItemCount(usableSlot)
- amountCraftable = math.floor(pezzi/9)
- print (amountCraftable)
- turtle.transferTo(6,amountCraftable)
- turtle.transferTo(7,amountCraftable)
- turtle.transferTo(8,amountCraftable)
- turtle.transferTo(10,amountCraftable)
- turtle.transferTo(11,amountCraftable)
- turtle.transferTo(12,amountCraftable)
- turtle.transferTo(14,amountCraftable)
- turtle.transferTo(15,amountCraftable)
- turtle.transferTo(16,amountCraftable)
- end
- function craft()
- turtle.select(craftingSlot)
- turtle.craft()
- end
- function unloadCrafted()
- turtle.turnRight()
- turtle.select(craftingSlot)
- turtle.drop()
- turtle.turnLeft()
- end
- function unloadRemnant()
- turtle.turnLeft()
- for i = 1, 5 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnRight()
- end
- function craftableSlot()
- -- verifica quale slot ha almeno 9 oggetti. Ritorna lo slot oppure 0 se nessun slot è compatibile
- for i=1, 5 do
- pezzi = turtle.getItemCount(i)
- if pezzi >= 9 then return (i) end
- end
- return 0
- end
- while true do
- -- la turtle guarda il giocatore. Come prima cosa ruota a destra verso lo scrigno di carico
- -- prende i primi 5 stack
- getFromChest()
- -- se ci sono almeno 9 pezzi in uno dei primi 5 slot va al crafting altrimenti rimette nella chest
- usableSlot = craftableSlot()
- if usableSlot > 0 then
- prepareCrafting(usableSlot)
- unloadRemnant()
- craft()
- unloadCrafted()
- else
- print("Materiale insufficiente")
- unloadRemnant()
- sleep(17)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment