5E Reading contents of local variable
Hello! I wrote this extension: https://www.fantasygrounds.com/forum...-Mirror-Image), however, it suffers from 2 problems, which I hope to solve:
- It is likely not compatible with other extensions that change the attack mechanics
- Passing of values from one resultHandler to another is very inellegant
So, the first problem:
In the ActionManager, (5E\scripts\manager_action_attack.lua), a resultHandler for `attack` is registered. The implementation of the handler registration can be found in (CoreRPG\scripts\manager_actions.lua) and it looks as follows:
Code:
local aResultHandlers = {};
function registerResultHandler(sActionType, callback)
ActionsManager.initAction(sActionType);
aResultHandlers[sActionType] = callback;
end
For my extension to be compatible for others, I need to save the already existing handler, so that I can call it from my implementation when necessary. But how do I do that? The variable aResultHandlers is local, and there is no getter.
Second problem:
From the resultHandler of `attack`, I need to pass an object to another resultHandler. However, to my knowledge, all of the parameters to ActionManager.performAction, are only shallow copied, meaning I cant pass an actual object there.
What I did to solve this, is to instead have a global map of objects, and to pass the object to the other handler, I save it in the map, and put the key of that object in the roll that gets passed to ActionManager.performAction. I then read this key in the other handler, and then read the object from the map. Is there any other way?