LuaControl::insert() optionally drops item on overflow
LuaControl::insert() optionally drops item on overflow
Currently inserting objects is a bit of a complicated process involving checking available space. It would be nice if insert had an optional flag that would drop items on the ground in the case of an overflow. Currently if there is no space for an insert call then the items are lost and this needs to be handled separately.
Re: LuaControl::insert() optionally drops item on overflow
You don't have to check available space, insert() returns the number of items inserted.
--for 1 item this works great
if entity.insert({name="stone-furnace"}) ~= 1 then surface.spill_to_ground(yadaya, the name of this function might not be correct but it will point you in the right direction) end
for a count of items you can do it almost the same
local count=10
local inserted = entity.insert({name="stone-furnace"})
if inserted ~= count then ---------- end
--for 1 item this works great
if entity.insert({name="stone-furnace"}) ~= 1 then surface.spill_to_ground(yadaya, the name of this function might not be correct but it will point you in the right direction) end
for a count of items you can do it almost the same
local count=10
local inserted = entity.insert({name="stone-furnace"})
if inserted ~= count then ---------- end