Event on_entity_logistic_slot_changed not always triggered
Posted: Mon Jan 27, 2025 1:29 pm
Hi!
For my mod Find Unfiltered Storage Chest I need to know when the filter of a Storage Chest has changed, so that I can update whether a warning should be shown for the chest.
When the filter is changed by a player via the entity GUI, this triggers the event `on_entity_logistic_slot_changed`. However, there are several other cases where the filter is changed but the event is not triggered.
1. Copy-pasting the entity settings via shift-clicking. In that case I can work around it by listening for `on_entity_settings_pasted`, but it feels inconsistent that it doesn't trigger `on_entity_logistic_slot_changed` as well.
2. Overwriting the entity settings using a blueprint: Place a storage chest without filter. Then, create a blueprint of a storage chest WITH a filter, and place it on top of the first storage chest. The game will overwrite the entity settings and set the filter, but no event is triggered that indicates this change.
For this one I haven't found a workaround yet. The only event I can see in that case is `on_pre_build`, which doesn't contain any information apart from the position the player clicked at (which might not even correspond to the chest if the blueprint contains more entities).
3. Undo/redo of a "copy-entity-settings" action. The event data here is a bit more helpful, it contains the entity prototype and the entity position. However, it doesn't contain the *surface* of the entity, so my current workaround is to find every storage chest at the given position on every existing surface and update it. Works, but it's quite hacky. :/
4. (Another edge case that came to my mind might be when the filter is changed by a mod by writing to the `storage_filter` property. I haven't tested if this triggers the event, but my guess would be that it doesn't.)
So my request: Would it be possible to trigger the `on_entity_logistic_slot_changed` event in these cases (most importantly the 2. case)? Or is there some specific reason why this can't be reasonably done?
Thanks a lot in advance!
For my mod Find Unfiltered Storage Chest I need to know when the filter of a Storage Chest has changed, so that I can update whether a warning should be shown for the chest.
When the filter is changed by a player via the entity GUI, this triggers the event `on_entity_logistic_slot_changed`. However, there are several other cases where the filter is changed but the event is not triggered.
1. Copy-pasting the entity settings via shift-clicking. In that case I can work around it by listening for `on_entity_settings_pasted`, but it feels inconsistent that it doesn't trigger `on_entity_logistic_slot_changed` as well.
2. Overwriting the entity settings using a blueprint: Place a storage chest without filter. Then, create a blueprint of a storage chest WITH a filter, and place it on top of the first storage chest. The game will overwrite the entity settings and set the filter, but no event is triggered that indicates this change.
For this one I haven't found a workaround yet. The only event I can see in that case is `on_pre_build`, which doesn't contain any information apart from the position the player clicked at (which might not even correspond to the chest if the blueprint contains more entities).
3. Undo/redo of a "copy-entity-settings" action. The event data here is a bit more helpful, it contains the entity prototype and the entity position. However, it doesn't contain the *surface* of the entity, so my current workaround is to find every storage chest at the given position on every existing surface and update it. Works, but it's quite hacky. :/
4. (Another edge case that came to my mind might be when the filter is changed by a mod by writing to the `storage_filter` property. I haven't tested if this triggers the event, but my guess would be that it doesn't.)
So my request: Would it be possible to trigger the `on_entity_logistic_slot_changed` event in these cases (most importantly the 2. case)? Or is there some specific reason why this can't be reasonably done?
Thanks a lot in advance!