Page 1 of 1
Force-based alert creation
Posted: Sun Apr 05, 2026 8:29 pm
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.
Re: Force-based alert creation
Posted: Sun Apr 05, 2026 8:44 pm
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”
Re: Force-based alert creation
Posted: Sun Apr 05, 2026 11:51 pm
by protocol_1903
That's fine, it just makes things simpler for mod developers.
Re: Force-based alert creation
Posted: Mon Apr 06, 2026 3:24 am
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.
Re: Force-based alert creation
Posted: Mon Apr 06, 2026 1:49 pm
by Rseding91
Ok, I added add_alert, add_custom_alert, and remove_alert to LuaForce for 2.1.