Page 1 of 1

Get entities created by spill_item_stack?

Posted: Sat Mar 07, 2020 9:14 am
by Thalassicus
How do I get the entities created by LuaSurface::spill_item_stack()?

I tried the code below. It creates the entities, but nearbyLoot is empty.

Code: Select all

local loot = {name="iron-plate", count=10}
event.entity.surface.spill_item_stack(event.entity.position, loot)

local nearbyLoot = event.entity.surface.find_entities_filtered{
  position=event.entity.position,
  radius=10,
  name=loot.name
}
if next(nearbyLoot) == nil then
  log("no nearby loot")
  return
end

Re: Get entities created by spill_item_stack?

Posted: Sat Mar 07, 2020 9:27 am
by Deadlock989
Spilled items are an entity named "item-on-ground". They have a "stack" property which describes what item the entity represents.