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

Post your bugs and problems so we can fix them.
Post Reply
Veden
Filter Inserter
Filter Inserter
Posts: 289
Joined: Wed Jul 13, 2016 3:54 pm
Contact:

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

Post 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
Attachments
testUnitGroups.zip
(979.83 KiB) Downloaded 60 times
testUnitGroups_0.0.1.zip
(847 Bytes) Downloaded 60 times

Post Reply

Return to “Bug Reports”