Posted 17 August 2013 - 11:20 PM
How to check fail-proof a turtle's inventory status ?
I am writing a turtle program for excavating tunnels, rooms or quarries. I would like the turtle to check its inventory before every dig order. This should prevent any precious minerals dropping to ground or in worst case burnt in lava.
I could compare every slot of the turtle with the block in front of it and check if there is at least space for 5 items (e.g. Redstone dropping up to 5 pieces of dust). But this get very slow after several slots of the turtle contains at least 1 item. The function turtle.select( … ) is so slow.
If I try to keep the inventory status in a table, I am running into other problems. A player could manually empty some slots of the active turtle and confuse the turtle this way. Or some minerals have a varying amount of drops.
The fastest and secure way I have found so far is to check if there is at least one completely free slot left. This leads to a turtle that returns with a not optimized filled inventory.
I am writing a turtle program for excavating tunnels, rooms or quarries. I would like the turtle to check its inventory before every dig order. This should prevent any precious minerals dropping to ground or in worst case burnt in lava.
I could compare every slot of the turtle with the block in front of it and check if there is at least space for 5 items (e.g. Redstone dropping up to 5 pieces of dust). But this get very slow after several slots of the turtle contains at least 1 item. The function turtle.select( … ) is so slow.
If I try to keep the inventory status in a table, I am running into other problems. A player could manually empty some slots of the active turtle and confuse the turtle this way. Or some minerals have a varying amount of drops.
The fastest and secure way I have found so far is to check if there is at least one completely free slot left. This leads to a turtle that returns with a not optimized filled inventory.