[0.16.51] trigger_created_entity has wrong force

Bugs that are actually features.
Post Reply
Forty-Bot
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Nov 24, 2018 9:07 pm
Contact:

[0.16.51] trigger_created_entity has wrong force

Post by Forty-Bot »

In data.lua:

Code: Select all

data.raw.projectile["atomic-rocket"].action.action_delivery.target_effects[2].trigger_created_entity = true
In control.lua:

Code: Select all

script.on_event(defines.events.on_trigger_created_entity, function (e)
    game.print(e.entity.name .. " " .. e.entity.force.name)
end)
When firing the rocket, the output is "explosion neutral", but the expected output is "explosion player" since the player shot the rocket, so the created entity should be on the players' force. Additionally, despite create-trivial-smoke being a subtype of create-entity, trigger_created_entity appears to do nothing (this can be tested by using [1] instead of [2] in the snippet above).

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [0.16.51] trigger_created_entity has wrong force

Post by Klonan »

This isn't a bug

It isn't that explosion is created with the wrong force,
It is that explosion has no force, so it always reads and acts as 'neutral'.

Create trivial smoke is a distinct trigger effect from the created entity, and wasn't programmed to trigger the event

Forty-Bot
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Nov 24, 2018 9:07 pm
Contact:

Re: [0.16.51] trigger_created_entity has wrong force

Post by Forty-Bot »

It is that explosion has no force, so it always reads and acts as 'neutral'.
So can we change that? It's created by something with a force (the projectile). I'm using it to create other effects at run-time which are force-dependent, so I would like some way to get the original force from this event. In any case, this behaviour is non-intuitive. And this still doesn't change that other subtypes of create-entity should still create this event.

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.16.51] trigger_created_entity has wrong force

Post by posila »

Forty-Bot wrote:
Sun Nov 25, 2018 1:40 am
So can we change that?
No. Make the projectile trigger spawn an entity that has force instead (for example something based of simple-entity-with-owner).

EDIT:
Forty-Bot wrote:
Sun Nov 25, 2018 1:40 am
And this still doesn't change that other subtypes of create-entity should still create this event.
create-trivial-smoke trigger effect is not subtype of create-entity trigger effect.

trivial-smoke is not an entity (in Factorio's sense of entity), it has its own LuaSurface::create_trivial_smoke function, and it's not possible to access existing trivial smokes from lua context (for example by using LuaSurface::find_entities)

Forty-Bot
Manual Inserter
Manual Inserter
Posts: 3
Joined: Sat Nov 24, 2018 9:07 pm
Contact:

Re: [0.16.51] trigger_created_entity has wrong force

Post by Forty-Bot »

create-trivial-smoke trigger effect is not subtype of create-entity trigger effect.
It says it is on the wiki
Inherits all properties from Types/TriggerEffectItem.

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

Re: [0.16.51] trigger_created_entity has wrong force

Post by Rseding91 »

Forty-Bot wrote:
Mon Nov 26, 2018 12:19 am
create-trivial-smoke trigger effect is not subtype of create-entity trigger effect.
It says it is on the wiki
Inherits all properties from Types/TriggerEffectItem.
Correct. It doesn't extend https://wiki.factorio.com/Types/CreateE ... EffectItem as everything that does extend it says.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Not a bug”