I would like the game to have an event defines.events.on_alert_added that will fire when a new alert is added to LuaPlayer::get_alerts(). Or maybe on_alerts_changed for any changes in get_alerts(), but with the ability to distinguish if a new one was added or an existing expired.
I'm making Dynamic HUD mod. It hides "unnecessary" UI. The goal here is to hide the alerts panel using GameViewSettings::show_alert_gui if there were no recent enough changes in LuaPlayer::get_alerts().
Unfortunately I couldn't find a proper event for when to check get_alerts(). A workaround I plan to use for now is to use on_nth_tick to check alerts once in a few seconds + show/check alerts on on_entity_damaged.
The downside of the workaround is that only damage-related alerts will be shown "urgently". All other alerts will be presented to the player with a delay for up to a few seconds. Which is not ideal. Also up until now I was able to avoid adding a permanently running on_nth_tick task. Adding something that affects ups for a measly goal of UI hiding doesn't feel right.
New event type: on_alert_added
Re: New event type: on_alert_added
By asking us to add the events engine side it would then take all of the work you're currently doing and make the engine do it *at all times* regardless of any mod listening to or doing anything in reaction to those events.Adding something that affects ups for a measly goal of UI hiding doesn't feel right.
So, instead of "if you use this mod, it might take some time to do what the mod is doing" it becomes "the engine always takes some time to track and send events that maybe somebody is listening to".
If you want to get ahold of me I'm almost always on Discord.
Re: New event type: on_alert_added
Well, basically yes. Just like with all the other events sent by the engine.
Unlike mod. A mod on the other hand would have to run a timer 100% of the time just to know if the event happened.
If the engine does require to constantly do more compute per ups even when nothing happens with alerts, then yeah the proposal is not worth it.
Unfortunately I'm not knoledgeable enough about the engine internals to know how impactful it is to add a new event. I just thought it should be the other way around. I assumed the "engine" is able to know when (A) it itself adds a new alert to itself and (B) if someone is listening. And it wouldn't requre more compute to detect that its time to send corresponding event.take all of the work you're currently doing and make the engine do it *at all times*
Unlike mod. A mod on the other hand would have to run a timer 100% of the time just to know if the event happened.
If the engine does require to constantly do more compute per ups even when nothing happens with alerts, then yeah the proposal is not worth it.

