Callback Priority System#339
Conversation
|
I've tried to do it further by allowing modder to see their callback's order and manipulate them, but it can't seem to return the value for some reason. |
|
Here are my thoughts.
|
This is not really a new feature. In the vanilla script, when you re-register the callbacks, it just do nothing, since it just set the value to the same key again. And if you’re concerned about priority, my point is that we have been using the callbacks with completely random orders each time, and there is no problem with it. I’ve tried keep everything the same but just open new possibilities for new scripts |
I will avoid reduce the order by avoid using size_table and instead just create a separate table to handle the next order number will be. |
Callback Priority System
|
I moved the changes to |
I didnt think its allowed for modded exe but ok, thats good |
Callback Priority System
Callback Priority System
Make callbacks don't select a random function to run each time ("in pairs" order is randomized)
Now it's ordered based on when you registered it.
Example:
When you have 2 scripts, "aaa.script" and "zzz.script" register its call back in "on_game_start" function. The "zzz" one will run later, hence register its callback after aaa's. That's mean the order of the callback function would be: aaa first, then zzz.
But what if aaa's callback want to override the changes of zzz's callback?
Then, aaa can re-register its callback again, in a later time, like using TimeEvent or register its callback in the "actor_on_first_update", to put it at a higher priority.
Re-register callback will move the function to the highest priory, without the need to unregister it first.
This changes mainly to solve the clear priority issue in callbacks like
on_before_play_hud_soundthat require Lua code to return value to the engine. But can be used further to manipulate values in the same callback without the fear of priority.This info is also in
axr_main_patches.script