OK, so I have a dynamic property ($Stability$) on a piece with the property being either 0 (stable) or 14 (unrest). This is necessary as the property is used in a calculated property to adjust the layer being displayed for the province piece.
What I’d like to do is create a hotkey (ctrl+X) to toggle between the two states. However, if I create a pair of triggers looking for ctrl+X and comparing that against an expression to determine which command to activate (set $Stability$ to 0 or Set $Stability$ to 14), the order of the triggers will mean that it always fails in one direction.
If i have it check for “is stable?” first, then it will change to unrest, then it will check for unrest and send back to stable. I can’t figure out a way to have it ‘stop’ after successfully matching an expression.
Any ideas?
Unless I’m missing something, I don’t think you need to use Triggers at all. You can implement that toggling functionality within the DP itself:
Cheers,
Jim Hunter.
Are there two states, or three? Initially you said the value of Stability
can be 0 or 14, now there’s a 7 as well.
If you want to do this with Triggers, double them up like you are thinking (pair of Triggers both bound to Ctrl+X
), but craft the property match expressions such that one of the two Triggers will always fail.
One Trigger would have a PME of {Stability==14}
and perform the key command that sets Stability
to 0. The other will have a PME of {Stability==0}
and perform the key command that sets Stability
to 14.
EDIT: Struck a bunch of wrongness, see below. Apologies.
The aforementioned solution is tidier.
Joel, the 2 triggers doesn’t work because they fire sequentially, not simultaneously, and therefore whichever one fires second will always be triggered (either because the first one didn’t, so the condition for the 2nd was already set, or because the first one did, so now the condition for the 2nd one is set!). Jim provided the best solution; the other solution is to add a “flag” GP, and have Ctrl-x
set the flag to true, add the flag being true to the conditions, and add setting the flag to false to the triggers…much more complicated.
Sorry Joel! Typo in my OP. I meant that it would be 0 or 14 (ignore the 7, I’ve edited it).
Huh, I’m not familiar with the code you put into the prompt. Is that an If/Else statement in shorthand?
Ah, I found it called a “Ternary” expression in the vassal documentation. Thanks!