Page 1 of 1
[0.16.51] trigger_created_entity has wrong force
Posted: Sat Nov 24, 2018 9:17 pm
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).
Re: [0.16.51] trigger_created_entity has wrong force
Posted: Sat Nov 24, 2018 9:21 pm
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
Re: [0.16.51] trigger_created_entity has wrong force
Posted: Sun Nov 25, 2018 1:40 am
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.
Re: [0.16.51] trigger_created_entity has wrong force
Posted: Sun Nov 25, 2018 8:09 am
by posila
Forty-Bot wrote: Sun Nov 25, 2018 1:40 amSo 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 amAnd 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)
Re: [0.16.51] trigger_created_entity has wrong force
Posted: Mon Nov 26, 2018 12:19 am
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.
Re: [0.16.51] trigger_created_entity has wrong force
Posted: Mon Nov 26, 2018 1:02 am
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.