-
May 3rd, 2021, 02:31 #1
ActionsManager.registerModHandler for Table Roll Script
Hey everyone,
I'm not sure if I can articulate this clearly... I have a button on the character sheet that rolls a specified die on a specified table, and the roll is modified by one of the ability score modifiers. I want to set up a modRoll function that checks for any ability effects from the combat tracker. I tried this:
Code:function onInit() ActionsManager.registerModHandler("table", modRoll); end
Code:function performRoll(draginfo, rActor) local rRoll = getRoll(rActor, rTarget); TableManager.performRoll(nil, rActor, rRoll, true); end
The modRoll callback (not shown here) does not run. Does anyone have any ideas why this isn't working? Maybe this doesn't work with the TableManager.performRoll function?
Thanks,
LeoLast edited by leozelig; May 3rd, 2021 at 11:47.
-
May 3rd, 2021, 03:42 #2
I have only worked with MoreCore rollers thus far. I looked at this for two reasons, 1) everyone is always helping me - so figured take a look even if it isn't my expertise. 2) Looking is learning - maybe I'll actually remember what I find in months when do non MoreCore. But maily #1, I know my memory sucks.
I found in CoreRPG manager_actions.lua the following:
Code:function applyModifiers(rSource, rTarget, rRoll, bSkipModStack) local bAddModStack = ActionsManager.doesRollHaveDice(rRoll); if bSkipModStack then bAddModStack = false; elseif GameSystem.actions[rRoll.sType] then bAddModStack = GameSystem.actions[rRoll.sType].bUseModStack; end local fMod = aModHandlers[rRoll.sType]; if fMod then local bReturn = fMod(rSource, rTarget, rRoll); if bReturn ~= true then rRoll.aDice.expr = nil; end end ...
Debug.console(rRoll)
Debug.console(rRoll.sType) (to isolate clearer)
and after the
local fMod = aModHandlers[rRoll.sType];
Debug.console("fMod=", fMod)
or something?
----
Presumably rRoll's name matches the name you passed on the ModHandler?Last edited by Varsuuk; May 3rd, 2021 at 03:47.
-
May 3rd, 2021, 11:12 #3
Thanks, Varsuuk. I confirmed that rRoll.sType matches the ModHandler and bAddModStack is true. The ModStack works, but the modRoll function doesn’t run. I will try your suggestions to see what is getting passed to the applyModifiers function.
Last edited by leozelig; May 3rd, 2021 at 11:49.
-
May 3rd, 2021, 18:23 #4
In middle of my own debugging at work (email alert caught my eye) so can’t look even if had info just now. But, before forget, I tested this when I was adding my turn undead roll to my morecore based thing.
I tried my suspicion and recall I was right. Setting that flag just stops the mod box updates (prob same for the buttons, didn’t have any yet to test) but does not affect onModHabdler- that is called if you define it it is separate from the book flag.
-
May 3rd, 2021, 22:14 #5
Yes, that seems to be the case with bAddModStack. I changed the roll type from "table" to "critical", which is defined in GameSystem.actions, but that didn't help. I'm just wondering if it has something to do with the TableManager.performRoll function not going through the same action sequence.
-
May 3rd, 2021, 22:46 #6
You might want to look at MoreCore’s roller handling (just search on addModHandler or whatever called. I’m burnt out about to pass out on couch or would look.
I find tracing what gets done when a sample morecore_custom_dbdamage.lua or whatever sample handler is setup might give you clues?
Did you get to see what the logging said?
Love to help if can. If it’s in your DCC I have that Ruleset and could try adding your new code by hand into mine if it is limited to one or two file changes later tonight after nap :?
-
May 3rd, 2021, 23:38 #7
Here's the Debug output from applyModifiers:
rRoll
{ s'aDice' = { #1 = s'd20' }, s'nMod' = #1, s'sNodeTable' = s'tables.id-00039', s'sType' = s'table', s'sDesc' = s'[TABLE] Table 7-1: Artifact Checks [+1]', s'sOutput' = s'', s'bSecret' = bFALSE }
fMod
fn
It looks like sType is changing to 'table' after it gets passed to TableManager for the roll, even if I define the roll as something else in my getRoll function. But even if the roll type is 'table', the modRoll function isn't running.
I'm going to move on to something else, but let me know if you have any ideas.Last edited by leozelig; May 3rd, 2021 at 23:51.
-
May 4th, 2021, 08:51 #8
Is this from CoreRPG ActionsManager.applyModifiers? If so, add some debug to make sure that the if fMod then code is actually running. If it is, and debug in your first line of code in the registered function modRoll doesn't run (I'm making assumptions you've done this to confirm if the function is running) is not running, then it sounds like there's an issue with the registered function - as that code within if fMod then wouldn't run unless there's a mod handler function registered for the roll type.
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
May 4th, 2021, 12:44 #9
Yes, 'if fMod' is running. Here is the debug output for aModHandlers:
{ s'artifact' = fn, s'dice' = fn, s'init' = fn, s'airecognition' = fn, s'save' = fn, s'skill' = fn, s'cast' = fn, s'heal' = fn, s'table' = fn, s'check' = fn, s'damage' = fn, s'attack' = fn }
The mod handler for 'artifact' seems to be registering, but it doesn't run. The ActionArtifact script sends the roll data to TableManager for the roll, so I'm thinking that's where things are getting lost.
-
May 4th, 2021, 13:43 #10
Any mod handler is based on the name of the action type name, stored in rRoll.sType. If you're calling TableManager.performRoll to make your roll, that sets rRoll.sType = "table" - so any handlers need to be registered with a name of "table". That seemed to be what you're doing based off post #1 but now you're mentioning "artifact". Can you take a step back and detail exactly what it is you're doing?
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks