Page 1 of 1

[2.0.60] Leaving remote map view does not raise on_selected_entity_changed

Posted: Sat Jul 19, 2025 2:52 pm
by Honktown
What you expected:
Deselecting an entity always raises on_selected_entity_changed when it's reasonable to do so.

What happens:
It doesn't. The tooltip changes and everything

To reproduce:

Code: Select all

/c
script.on_event(defines.events.on_selected_entity_changed, function(event)
	game.print(event.tick)
end)
1) open the map, zoom in, put the mouse cursor on something (event raises)
2) press m to leave map view (event doesn't raise) even though the entity is deselected according to the tooltip

Re: [2.0.60] Leaving remote map view does not raise on_selected_entity_changed

Posted: Sun Jul 20, 2025 1:49 pm
by Rseding91
I suspect this will be a case of “won’t fix”/“not a bug”. There are a handful of cases where the engine suppresses lua events because it is not and cannot reasonably be setup to handle if some mod did something annoying during the event.

Exiting remote view can happen for one of many reasons - such as a hub dying and the player being force ejected. In that case we can’t allow a lua event because a mod may try to put the player back in the hub which is half dead.

Re: [2.0.60] Leaving remote map view does not raise on_selected_entity_changed

Posted: Mon Jul 21, 2025 8:17 pm
by Rseding91
Looking into this more, the reason the event doesn't fire is due to a technicality: the selected entity has not changed on the controller - just the active controller changed. The remote controller - in its inactive state - still has that entity selected.

However, I can't add the event when exiting remote view because of the previous mentioned reason.

Re: [2.0.60] Leaving remote map view does not raise on_selected_entity_changed

Posted: Mon Jul 21, 2025 11:31 pm
by Honktown
Thanks for replying. I think watching on_player_controller_changed, in addition, might solve my mod's "issue" then.