PDA

View Full Version : Issue with ActionsManager.registerModHandler



Brenn
June 4th, 2015, 10:15
I'm having issues with the following code:


function onInit()
ActionsManager.registerModHandler("dice", modRoll);
ActionsManager.registerResultHandler("dice", onRoll);
end


function modRoll(rSource, rTarget, rRoll)
Debug.chat("ModRoll");
end


function onRoll(rSource, rTarget, rRoll)
Debug.chat("onRoll");


end


I get the onRoll in chat when I throw a die from the desktop, however I do not get the ModRoll.
Any clues?

I've gone so far as to run a modded version of core with the following changes in manager_actions:


function applyModifiers(rSource, rTarget, rRoll, bSkipModStack)
Debug.chat("Apply Modifiers");
local bAddModStack = (#(rRoll.aDice) > 0);
if bSkipModStack then
bAddModStack = false;
elseif GameSystem.actions[rRoll.sType] then
bAddModStack = GameSystem.actions[rRoll.sType].bUseModStack;
end


Debug.chat("RollType: ",rRoll.sType);
local fMod = aModHandlers[rRoll.sType];
if fMod then
fMod(rSource, rTarget, rRoll);
end
...
end



I get the "RollType: | dice" in chat when I throw a die from the desktop, which means that fMod should equal aModHandlers["dice"], right? And I registered it in my other code so it should be there... however it never does fire. I'm baffled.

Brenn
June 4th, 2015, 12:16
Ok I've done something else, actually inherited this ruleset from my modded core and now I never get to applyModifiers. I know what my problem is related to- getting rid of the stock Modifier stack control on the desktop. Something with the targeting code (I think) is causing ApplyModifiers to not get called... Actually it is right here where it breaks down (I get to debug 1 but not 2 or 3):



function actionRoll(rSource, vTarget, rRolls)
Debug.console("actionroll 1");
local bModStackUsed = false;
lockModifiers();

for _,vTargetGroup in ipairs(vTarget) do
Debug.console("actionroll 2");
for _,vRoll in ipairs(rRolls) do
Debug.console("actionroll 3");
if applyModifiersAndRoll(rSource, vTargetGroup, true, vRoll) then
bModStackUsed = true;
end
end
end

unlockModifiers(bModStackUsed);
end

Brenn
June 4th, 2015, 12:41
Ok I worked around this. I had originally done a merge = "delete" with the modifierstack panel. I replaced with this and it is functional:


<panel name="modifierstack" merge="join">
<bounds>0,0,0,0</bounds>
<disabled />
</panel>


I know this has to do with my lack of understanding of the targeting stuff. I'll figure it out eventually. Really don't need to go to deep into it for what I'm doing though.