Page 1 of 1

[1.1.32] Unit groups missing on units in the on_entity_died event

Posted: Sat May 01, 2021 3:35 am
by Veden
Summary:
Unit groups are nil on units during the on_entity_died event.

Long version:

If you load the attached save with the attached mod, you can run the command below in the console to generate a unit group with 10 small biters.
The unit group will spawn close enough to turrets to agro the unit group.

The command when run will print the unit number and the group number of each biter.
The mod contains a hook for the on_entity_died event, where the code prints out the unit number and the group the dying biter is associated with.

None of the biters passing through the on_entity_died contain a unit_group

Code: Select all

local surface = game.surfaces[1]

local group = surface.create_unit_group({position={0,0}})

for i = 1, 10 do
    local e = surface.create_entity({
            position = {0,0},
            name = "small-biter"
    })
    group.add_member(e)
    print("unit", e.unit_number, "group", e.unit_group.group_number)
end

Re: [1.1.32] Unit groups missing on units in the on_entity_died event

Posted: Mon May 24, 2021 8:17 pm
by Rseding91
Thanks for the report. It's now fixed for the next release.