Force-based alert creation

User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 479
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Force-based alert creation

Post by protocol_1903 »

I would like to be able to create alerts for an entire force, without having to iterate over force.players. This would also solve the issue of players joining late and not having existing alerts. Ideally, it would be a set of methods on LuaForce that mirror the alert-related methods on LuaPlayer: add_alert, add_custom_alert, remove_alert, get_alerts, etc. If not all of the functions, then just ones related to managing alerts, so instead of having to call it on each player you can just call it for the force.
pY and pYblock developer, wielder of fluid networks and subtick events in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903

Buy me a coffee
Rseding91
Factorio Staff
Factorio Staff
Posts: 16695
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Force-based alert creation

Post by Rseding91 »

The way alerts work on the engine side is to do exactly what you’re saying you don’t want to do.

It iterates players on the force and if they’re connected it adds the alert. Alerts aren’t touched on the engine side for offline players.

So if such methods did exist they would be functionally identical to “iterate force players and if connected interact with them”
If you want to get ahold of me I'm almost always on Discord.
User avatar
protocol_1903
Filter Inserter
Filter Inserter
Posts: 479
Joined: Fri Sep 09, 2022 4:33 pm
Contact:

Re: Force-based alert creation

Post by protocol_1903 »

That's fine, it just makes things simpler for mod developers.
pY and pYblock developer, wielder of fluid networks and subtick events in arbitrary ways. I make mods. Check them out, maybe.
https://mods.factorio.com/user/protocol_1903

Buy me a coffee
User avatar
PennyJim
Fast Inserter
Fast Inserter
Posts: 160
Joined: Wed Jan 18, 2023 3:49 am
Contact:

Re: Force-based alert creation

Post by PennyJim »

Theoretically having the engine iterate over the force players would be faster than a mod asking the engine to build a list of connected players and iterating it in Lua.

But this would also save from developers forgetting that they can pass the same table to each call and accidentally recreating it for every connected player.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16695
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Force-based alert creation

Post by Rseding91 »

Ok, I added add_alert, add_custom_alert, and remove_alert to LuaForce for 2.1.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Implemented mod requests”