PDA

View Full Version : Problem with modifierbuttons copied from 2E/5E ruleset



Tatzelbelm
May 7th, 2020, 19:32
Hi,

I've copied the modifierbuttons of the 2E/5E rulesets into Forbidden Lands extension for MoreCore.

This mostly works, the modifiers are applied correctly to the first roll after selecting the button.
After that, the buttons should reset their state - but they don't, at least the graphic does not. Visually, the buttons stay selected, although FG doesn't apply the modifier on further rolls.

I've spent over an hour searching through the rulesets to find the function which resets the graphic of the buttons, but didn't find it.
Can someone more familiar with this functionality give me pointer in which file I have to look?

Trenloe
May 7th, 2020, 20:23
Assuming you're using the CoreRPG based ModifierStack functionality - i.e. ModifierStack.getModifierKey(control_name) is what you use to get the state of the button, then it should reset as part of that command.

Tatzelbelm
May 7th, 2020, 20:43
Since I just copied the manager_actions2.lua from 2E that is exactly the command I'm using. It reads the button value just fine, but does not reset the graphical button state.
I have not modified the ModifierStack script, it's using the original CoreRPG script.

To elaborate:
I've added the controls like the 2E ruleset does in desktop_classes.xml (here's one button as an example):

<button_modifierkey name="PLUS1">
<bounds>5,8,15,18</bounds>
<text>+1</text>
</button_modifierkey>


Then I've added the manager_actions2.lua script to the extension, again copied from 2E and containing this function:


function encodeDesktopMods(rRoll)

local nMod = 0;

if ModifierStack.getModifierKey("PLUS1") then
nMod = nMod + 1;
end

if nMod == 0 then
return;
end

rRoll.nMod = rRoll.nMod + nMod;
rRoll.sDesc = rRoll.sDesc .. string.format(" [%+d]", nMod);

end


Finally, I'm now calling the encodeDesktopMods-function from the onDice-function of the extension, which replaces the resulthandler of CoreRPG.

This reads and applies the modifierboxes just fine, and also resets the "standard" modifierbox as normal. Further rolls also have no modifier applied. But the graphic state of the button stays pressed, and I have to manually unpress it before I can use it again to apply new modifiers.

Edit:
I think I found the issue in ModifierStack.getModifierKey:
Looking the code of the getModifierKey-function, it should indeed reset the button immediately, but for some reason it doesn't do it.
I'll have to insert some debugging output messages.

Thanks so far.

Tatzelbelm
May 9th, 2020, 13:04
Found the issue. I had copied just the buttons, they were not linked to the modifierstack window.
Because of that the function for resetting the buttons did not find the buttons using findWindow.