entity.caninsert() returns true despite the fact that entity's inventory is zero sized.
Workaround code:
Code: Select all
if entity.caninsert{name=item_name, count=count} then
entity.insert{name=item_name, count=1} -- the real test
if entity.getinventory(defines.inventory.fuel).getitemcount(item_name) >= 1 then
if count - 1 > 0 then
entity.insert({name=item_name, count=count-1})
end
end
end