PDA

View Full Version : extension coding question regarding modifier buttons



hehaub
September 27th, 2019, 22:00
Can anyone tell me where the functions are(or what they are called) that "unselect" these buttons on an attack die roll?
I am attempting to create a new extension that includes buttons that I would like to also have this triggered event reset
I am very new to lua, so I hope this is clear

Moon Wizard
September 27th, 2019, 22:20
The ModifierStack global script controls this portion of the ruleset. It's in the CoreRPG layer.

* setModifierKey(...) will set the value of the button, as well as register the key in the master modifier key list.

* getModifierKey(...) will return the value of the button, as well as reset the key state (if not locked) or track usage (if locked).

* lock() will increment the lock count

* unlock() will decrement the lock count, and reset any keys used if lock count is zero.

Regards,
JPG

hehaub
September 29th, 2019, 05:28
The ModifierStack global script controls this portion of the ruleset. It's in the CoreRPG layer.

* setModifierKey(...) will set the value of the button, as well as register the key in the master modifier key list.

* getModifierKey(...) will return the value of the button, as well as reset the key state (if not locked) or track usage (if locked).

* lock() will increment the lock count

* unlock() will decrement the lock count, and reset any keys used if lock count is zero.

Regards,
JPG

After checking this over, and many failed attempts I think what I was asking for was not clear. Thank you for your reply Moon Wizard. I think what I mean to ask is how to make the physical button "pop-up" so-to-speak.
For example, if I select a modifier in the modifier window, like "standard cover", it will pop back up after the roll hits the chatbox.
Mine is not doing that. However it does deactivate the code behind the button. In order to use this again, I have to toggle the button off then back on.
Is this what you were describing above? After looking at that, I think this is for the code behind the button. This portion is already working. Please let me know if I misunderstand.

hehaub
September 30th, 2019, 23:26
29210
Maybe a visual of what I am trying to do will help. As you can see, when I press the Attk2 button it depresses and the result on the roll is modified correctly.
The button stays down after the roll, even though if I roll again it is not "active" as shown in the image. So, I have to click the button to untoggle it.

This code will toggle the button if the other is pressed, and that part is also working

function onValueChanged()
super.onValueChanged();
if getValue() == 1 then
window["ATT_2"].setValue(0);
end
end

I have tried several things, but I am not having any luck with this. Any coding gurus want to toss me a hint?

Moon Wizard
October 1st, 2019, 01:00
Since you are not adding the button as part of the standard set of ModifierStack buttons; then you would need to add your own code within the attack roll handler to toggle the button off.

If instead you add those buttons to the "modifierstack" panel or to the "modifiers" window, then they would automatically be turned off, since that is where the global ModifierStack script is looking to automatically turn off the buttons. You can see the script code that does this in ModifierStack.setModifierKey(...).

Regards,
JPG