Event.on_alert_click

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Event.on_alert_click

Post by eradicator »

What?
An event that triggers when a player clicks an alert icon (i.e. missing robots, damaged entities etc). That contains the entity, icon, (unlocalized) message, and ideally a custom alert name.

Why?
While LuaPlayer.add_custom_alert() allows to add an alarm there is no callback if the player actually notices/reacts to the alarm. I'd like to show some additional GUI elements when the player clicks an alarm. For easier management it would be nice if LuaPlayer.add_custom_alert() was extended to include as additional parameter (or return value on call) a custom alert name/unique ID. A good example for this would be a classical "you have a new message" that opens the message. But existing mods would also benefit from this. For example ore-monitoring mods would being able to not only show a map position but for example also show the status display of a nearly depleted ore field and the estimated remaining usage time.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Event.on_alert_click

Post by Rseding91 »

I would add this in but at the moment the game doesn't know the alert was clicked. All of that logic it view-logic and outside the game state and as such mods can't access it without causing desyncs at the moment.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Event.on_alert_click

Post by eradicator »

Rseding91 wrote:I would add this in but at the moment the game doesn't know the alert was clicked. All of that logic it view-logic and outside the game state and as such mods can't access it without causing desyncs at the moment.
*sigh* Oh well. How are the chances of the GUI rewrite (0.17?) changing enough of the background logic to make this possible?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 513
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

Re: Event.on_alert_click

Post by Mylon »

Can this event be raised by the player? That is, when the player clicks an alert, the player's client builds the event context and sends it to the server?

It's a bit of a hack and I imagine would cause some delay, but it could work without a significant rewrite.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Event.on_alert_click

Post by Rseding91 »

Mylon wrote:
Fri Jul 10, 2020 1:59 pm
Can this event be raised by the player? That is, when the player clicks an alert, the player's client builds the event context and sends it to the server?

It's a bit of a hack and I imagine would cause some delay, but it could work without a significant rewrite.
That's how all events work currently.
If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Event.on_alert_click

Post by eradicator »

Rseding91 wrote:
Fri Jul 10, 2020 3:14 pm
So. Now two and a half years and a gui rewrite later, any chance of this happening?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13204
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Event.on_alert_click

Post by Rseding91 »

eradicator wrote:
Fri Jul 10, 2020 3:17 pm
Rseding91 wrote:
Fri Jul 10, 2020 3:14 pm
So. Now two and a half years and a gui rewrite later, any chance of this happening?
gui rewrite has nothing to do with this. The game-state still does not know anything happened because it's all view logic - the same as before - nothing is sent to the server - no input action is created.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding interface requests”