[1.1.110] on_trigger_created_entity not raised by create-smoke and create-explosion

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
k2aj
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Jul 11, 2024 2:10 pm
Contact:

[1.1.110] on_trigger_created_entity not raised by create-smoke and create-explosion

Post by k2aj »

Caught this while trying to code a custom ammo which spawned poison clouds (I was trying to use on_trigger_created_entity to do something with the spawned poison cloud after it was was created).

CreateEntityTriggerEffectItem has a field called trigger_created_entity. According to modding API documentation, if this is set to true on_trigger_created_entity will be raised when the entity is created.

The bug: this only works for CreateEntityTriggerEffectItem and CreateFireTriggerEffectItem. CreateSmokeTriggerEffectItem and CreateExplosionTriggerEffectItem don't raise the event, even though they inherit from CreateEntityTriggerEffectItem.

Steps to reproduce:
  1. Install the attached mod (trigger-created-entity-bug-report_0.1.0.zip)
    • The mod registers a listener for on_trigger_created_entity which prints a global chat message when that event is raised.
  2. Load the attached save file (trigger-created-entity-bugreport-save.zip)
    • The player starts with 4 types of custom shotgun shells in their inventory.
    • Each shotgun shell when fired will create an entity at target position using CreateEntityTriggerEffectItem / CreateFireTriggerEffectItem / etc. with trigger_created_entity set to true (the shotgun shell name tells which TriggerEffectItem is used). This should cause a message to be printed in the chat due to the aforementioned event listener.
  3. Shoot each type of shotgun shell in the player's inventory at least once.
Observed behavior:
  • CreateEntityTriggerEffectItem and CreateFireTriggerEffectItem shotgun shells cause a message to be printed in chat when fired.
  • CreateSmokeTriggerEffectItem and CreateExplosionTriggerEffectItem shotgun shells do not cause a message to be printed in chat when fired.
Expected behavior:
All custom shotgun shells added by the mod cause a message to be printed in chat when fired.

Note:
In most cases this bug is easy to work around by replacing the use of CreateSmokeTriggerEffectItem / CreateExplosionTriggerEffectItem with CreateEntityTriggerEffectItem. However, this workaround is not obvious, and if someone isn't aware of the bug finding the workaround can take a significant amount of time (speaking from personal experience).

If this is intended behavior / too niche to fix, a note warning about this behavior in the documentation of CreateSmokeTriggerEffectItem / CreateExplosionTriggerEffectItem would be appreciated.
Attachments
factorio-current.log
(5.25 KiB) Downloaded 20 times
trigger-created-entity-bugreport-save.zip
(1.54 MiB) Downloaded 21 times
trigger-created-entity-bug-report_0.1.0.zip
(1.87 KiB) Downloaded 17 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 15010
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.110] on_trigger_created_entity not raised by create-smoke and create-explosion

Post by Rseding91 »

Technically, create-smoke and create-explosion are different triggers which do not include the "trigger_created_entity" logic.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Modding interface requests”