Page 1 of 1

spill_item_stack returns created entities

Posted: Sat Mar 07, 2020 8:09 am
by Thalassicus
It'd be helpful if LuaSurface::spill_item_stack() returned the table of items it create.

I made aliens drop loot, and I'm attempting to mark the loot for deconstruction after there's no more enemies in a certain radius. This time delay means I can't use the instantaneous deconstruction provided by spill_item_stack(). I must store the items in a list, and check the list periodically.

Re: spill_item_stack returns created entities

Posted: Tue Mar 10, 2020 1:38 pm
by Rseding91
Ok. I didn't want to do this in the past because it would make the function a lot slower returning all the entities every time but in the meantime I created a way of only returning the results if something is actually using them.

So, calling spill_item_stack() is as cheap as before and if you do something like: local results = surface.spill_item_stack() then you pay the cost of storing all the results.

Re: spill_item_stack returns created entities

Posted: Tue Mar 10, 2020 1:58 pm
by eradicator
Rseding91 wrote: Tue Mar 10, 2020 1:38 pm in the meantime I created a way of only returning the results if something is actually using them.
Could that also be applied to returning the ghost entity (if any) in LuaEntity.die()?