I’m trying to implement an “if X else-if Y else if Z” construction using triggers. In my specific case, it looks something like this:
if (PlayerSide == “Red”) then do red stuff via ^T
else if (PlayerSide == “White”) then do white stuff via ^T
else if (PlayerSide == “Blue”) then do blue stuff via.^T.
So a player knows ^T does his stuff, and he doesn’t have to remember a different keystroke depending on which side he is playing. In practice, ^T sends a unit to a spot on the board and updates some global properties, but different for each player.
In Vassal, I use triggers, and in shorthand form, here’s what each one looks like:
Trigger. property-match {PlayerSide==“Red”} Menu-command=“Send to my tray”. Key-command=^T.
Trigger. property-match {PlayerSide==“White”} Menu-command=“Send to my tray”. Key-command=^T.
Trigger. property-match {PlayerSide==“Blue”} Menu-command=“Send to my tray”. Key-command=^T.
The performed key commands vary depending on the player side.
When I test it and right-click on the piece, I see that the menu command is grayed out much to my chagrin. I’m guessing that vassal is “helping” me because it sees two impossible cases, so it grays out the menu text. I note that if I wanted it grayed out, I could use the “restrict command” trait. I also note that ^T still works even if the menu text is grayed out. Is there any way to stop this “help”?
I found a workaround with a fake “facade” command. I created a dummy dynamic property (called “dummy”) with a single command ^T and with menu text “Send to my tray”. All it did was set dummy=0. Then I had all the triggers watch for ^T. This worked. “send to my tray” is not grayed out.
The trouble with this is the future me, who looks at this code, is going to think this me is an idiot. I’m going to have to write an apology and explanation to future me as to why I had to do this apparently stupid thing.