2 posts
Posted 10 December 2012 - 12:45 PM
I'm trying to create a isInventoryFull function for my turtles (so they can return after mining their tunnels). I can't get one to work. How do I do this?
1688 posts
Location
'MURICA
Posted 10 December 2012 - 01:57 PM
function isInventoryFull()
for i=1, 16 do
if turtle.getItemSpace(i) > 0 then
return false
end
end
return true
end
The function turtle.getItemSpace() returns the amount of items needed to fill a certain slot. The logic of this function is that it goes through all of the slots of the turtle's inventory, and if it finds a slot that needs items to fill it, it stops and returns false, since it's obviously not full if a slot can receive items. Otherwise, if there are no slots that can have items, it returns true.