feat: add onInitFinal event for post-initialization synchronization#452
feat: add onInitFinal event for post-initialization synchronization#452Kipstz wants to merge 2 commits intoBeamMP:minorfrom
Conversation
Adds a new 'onInitFinal' event that triggers after ALL Lua states have completed their 'onInit' handlers. This provides a reliable synchronization point for inter-state communication. Use case: When multiple Lua states need to communicate (e.g., a centralized settings manager), they can now safely interact in onInitFinal knowing all states are fully initialized. Closes BeamMP#434
| auto DataPtr = std::make_unique<StateThreadData>(Name, StateId, *this); | ||
| mLuaStates[StateId] = std::move(DataPtr); | ||
| RegisterEvent("onInit", StateId, "onInit"); | ||
| RegisterEvent("onInitFinal", StateId, "onInitFinal"); |
There was a problem hiding this comment.
Why was this line added?
There was a problem hiding this comment.
Well, to create the event?
There was a problem hiding this comment.
That is something up to the scripter so that the server doesn't implicitly call functions.
There was a problem hiding this comment.
So why do it for “onInit”?
There was a problem hiding this comment.
I'm not entirely sure but it might be left over from the old scripting engine.
There was a problem hiding this comment.
Well, I know I just followed what had already been done at the time. I think the implementation is fine. If in the future we have to redo the entire basis of the system, I would do it again, but I find it a bit strange to do things halfway. We might as well redo everything properly in the future.
There was a problem hiding this comment.
I think the best solution would be to remove both of those calls and see if anything breaks.
Adds a new 'onInitFinal' event that triggers after ALL Lua states have completed their 'onInit' handlers. This provides a reliable synchronization point for inter-state communication.
Use case: When multiple Lua states need to communicate (e.g., a centralized settings manager), they can now safely interact in onInitFinal knowing all states are fully initialized.
Closes #434