LuaControl::insert() optionally drops item on overflow

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 525
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

LuaControl::insert() optionally drops item on overflow

Post by Mylon »

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.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: LuaControl::insert() optionally drops item on overflow

Post by Nexela »

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
Post Reply

Return to “Modding interface requests”