PDA

View Full Version : 5E registerPostRollHandler



jkeller
January 6th, 2026, 16:32
There seems to be a conflict between an extension I'm developing, and another one (for which I don't have the source code).

It looks like 5E (in manager_actions.lua) only supports a single PostRollHandler (instead of a list which seems better).
Also there's no get function for it, and it's local, so I can't access it (right?).



local aPostRollHandlers = {};
function registerPostRollHandler(sActionType, callback)
ActionsManager.initAction(sActionType);
aPostRollHandlers[sActionType] = callback;
end

I think a safe/compatible approach (if all extensions used it) would be something like this:



local ActionsManager_PostRollHandler = nil;

function registerHandlers()
ActionsManager_PostRollHandler = ActionsManager.aPostRollHandlers["damage"]; -- THIS DOESN'T WORK SINCE IT'S LOCAL
ActionsManager.registerPostRollHandler("damage", myOnDamageRollDecorator);
end

function unregisterHandlers()
-- only restore the old handler if this is the one currently registered
if ActionsManager.aPostRollHandlers["damage"] == myOnDamageRollDecorator then
ActionsManager.registerPostRollHandler("damage", ActionsManager_PostRollHandler);
end
ActionsManager_PostRollHandler = nil;
ActionsManager.unregisterPostRollHandler("damage", myOnDamageRollDecorator );
end

function myOnDamageRollDecorator (rSource, rRoll)
if ActionsManager_PostRollHandler then
ActionsManager_PostRollHandler(rSource, rRoll); -- call any other handler first
end
. . .

Otherwise, what are my options? I can set a high loadorder, but that's no guarantee. I'll try to work with the other extension developer of course.

Moon Wizard
January 7th, 2026, 18:40
I'm going to add a new "get" option for extensions that need to "chain" handlers.

Regards,
JPG

jkeller
January 7th, 2026, 19:07
Great, thank you!

jkeller
January 15th, 2026, 15:33
I'm going to add a new "get" option for extensions that need to "chain" handlers.

Regards,
JPG

Please consider doing the same for registerTargetingHandler; it's also local and limited to one handler with no getter.



local aTargetingHandlers = {};
function registerTargetingHandler(sActionType, callback)
ActionsManager.initAction(sActionType);
aTargetingHandlers[sActionType] = callback;
end

Moon Wizard
January 15th, 2026, 18:59
It's already in place in the Test channel for Targeting/Mod/Roll/Result handlers. It's limited to one handler by design; otherwise, things would get messy. The getter function just allows extension devs to chain easier.

Regards,
JPG

jkeller
January 15th, 2026, 20:24
Right, chaining is my intention. Thank you.