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
Re: caninsert() ignores inventory size
Posted: Wed Jul 16, 2014 4:52 am
by slpwnd
What entity is this exactly?
Re: caninsert() ignores inventory size
Posted: Wed Jul 16, 2014 9:22 am
by Dark
It is a car, with zero in fuel and inventory storage.
Mod that automatically placed fuel in any player build entities conflicted with it.
So the car and the character had dummy methods for caninsert (always returning true instead of checking the actual contents of their inventories). This will be fixed in the 0.10.4. Just a side note - caninsert will return true if anything can be inserted (so caninsert for 100000000 will succeed even if there is a single space).
Re: caninsert() ignores inventory size
Posted: Wed Jul 16, 2014 9:59 am
by Dark
Thanks. Still better than always true, a check for how much was actually inserted can be done manually.
BTW, can "insert" method return inserted amount? That would make things trivial.