in on_entity_died for worm turrets, cause is nil

Bugs that are actually features.
Post Reply
User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 513
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

in on_entity_died for worm turrets, cause is nil

Post by Mylon »

Summary:
Worm turrets do not report their cause on death.

Observed behavior:
event.cause is nil

Expected behavior:
event.cause is player (or turret, or car, or whatever)

To recreate:
Start a game and run these commands:

Code: Select all

/c game.player.surface.create_entity{name="small-worm-turret", position={50,0}}
/c script.on_event(defines.events.on_entity_died, function(event) game.print(event.cause) end)
Now go kill the worm (cheating may help)
Console prints: "nil"

Expected behavior: Lua error (trying to pass a non-string to game.print)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13251
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: in on_entity_died for worm turrets, cause is nil

Post by Rseding91 »

This is because worms don't die immediately when they reach 0 health but go through an animation stage.

"cause" is optional because it's not always available. This is one of those instances where it's not available.
If you want to get ahold of me I'm almost always on Discord.

Solinya
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Sun Mar 17, 2019 10:39 pm
Contact:

Re: in on_entity_died for worm turrets, cause is nil

Post by Solinya »

Bit of a gravedig because I've been investigating a change in mod behavior in 0.17.23.

For much of the 0.17.x branch, up through at least 0.17.17, even though event.cause is technically optional, it was being populated correctly for worm deaths. Now I'm finding on 0.17.23, worm turrets call on_entity_died with a nil cause.

Is it an intentional change to no longer populate the cause on worm turret deaths? And since it was working before, did something change that made that prior population no longer feasible?

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2904
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: in on_entity_died for worm turrets, cause is nil

Post by darkfrei »

Rseding91 wrote:
Sat Jun 03, 2017 8:16 pm
This is because worms don't die immediately when they reach 0 health but go through an animation stage.

"cause" is optional because it's not always available. This is one of those instances where it's not available.
How to disable this lag between starting of death and end of death? Units have that death animation too, but dying immediately.

Post Reply

Return to “Not a bug”