ssilk wrote: ↑
Sat Nov 02, 2019 12:49 am
Long awaited, Rseding. Thanks.
Still missing: Schedule time-events. E.g.:
- raise an event every 60 ticks, as payload the index-number of that event
- raise event in 200 ticks, then in 250, then in 480 ticks... (a list of wanted time-events plus some payload for that event)
And if this scheduler works:
- raise an event in a tick where no other event is raised (to use that unused CPU time and make background calculations)
1) there is event.on_nth_tick() if that is what you mean
2) scheduling will not work because lua functions cannot be serialized savely (most of the time/basically always), so upon save and load the events would be forgotten.
Although there is the possibility to store ids to functions instead of the functions themselfs, that would mean the mod has to register the same functions with the same ids every time upon loading a save (mod load)
(and migrate them properly)
3) i like that idea. might need like a max tick delay so it doesn't never run
My general thoughts:
I really like the filters
Though the current implementation of (core/lualib/)event_handler.lua does not work with them.
but i'm pretty sure it is possible to work with some changes.
only downside is, once a more generic system is using that eventhandler, it cannot rely on the filters it registered, since something else might have registered the same event but with different filters, and those have to be or-ed together.
maybe it's time for a (significantly more complex?) event system where you can subscribe multiple handlers to the same event. I mean that is basically what the event_handler is doing - on the lua side.