I’m trying to get a counter to rotate if certain conditions are met, mainly that it has moved and it’s location matches a predefined name.
However, in Trigger Action, I can’t ever seem to get $LocationName$ = X, where X is the location’s actual name as a string, to evaluate as true. I feel like I’m just not getting the format right for comparing a property value to a string. I made a little test module to show my problem. In this one, the location names are Point1 and Point2.
First I made a piece that rotates every time it is moved. No problem.
Then I wanted to limit that to every time the piece is moved and ends up at Point1. I did this by trying to put every combination of expressions I could think of into the Trigger When Properties Match box:
and so on and so forth.
I even put a Text Label on the piece for debugging purposes just to make sure the $LocationName$ is correct, and it shows the value of $LocationName$ just like I would expect.
Eliminating the restriction of the expression from the Trigger When Properties Match by leaving that box blank gets the piece to rotate, so it looks like the expression not evaluatng as I want it to is the problem.
How do I properly compare a Property to a string value in the Trigger When Properties Match box of Trigger Action?
With respect, do yourself a favour and read the reference manual before guessing. Highlighting ‘Trigger Action’ on the Piece Definer, then clicking on the Help button below it will take you straight to the relevent page. I know the reference manual page is not great and needs expansion, but why would you make all these wild guesses that look nothing like the example included:
HitPoints_Level < 2 && Wound_Active != true
Notice the lack of ‘$’ and ‘"’ in the published examples.
Believe me, I’ve spent hours looking over the reference manual. I read that and for some reason assumed that the examples didn’t need quotes because they were integers or boolean values rather than strings, and I assumed that strings would need quotes. Otherwise, as I reasoned it out, I would be comparing the string LocationName to the string Point1 if I didn’t somehow differentiate them by putting dollar signs or quotes or whatever.
But you’re exactly right. I don’t know how I didn’t try what you said before. I sure tried everything else. But I tried it and it worked perfectly.
Brent, I’ve gotten a lot of help from all the replies you’ve made on the forums explaining the many questions that have been posted. Thanks for helping me out yet again.
The format for Property Expressions is somewhat eccentric and could certainly be better documented.
One of the improvements I am working on for 3.2 is to incorporate the BeanShell scripting language
into Vassal. This will give you the option to specify Property Expressions using straight Java Syntax. This will normalise the syntax and allow proper parentheses handling.
I plan a major overhaul of the help information to go along with this.
You will also be able to include Java expressions anywhere that currently accepts ‘$variable$’ field references.
On the left-hand side should be a property name. No dollar signs.
On the right-hand side should be a string. Property values are substituted, so you’ll more commonly see dollar signs on the right. Otherwise, it’s a literal string, so don’t put quotes there unless you expect the value to contain quotes. Leading and trailing white space is trimmed, but otherwise spaces become part of the pattern to be matched. In your example, you want