Comparing properties

Is there a way to do something like the following (for example in a Trigger property check):

Type = Infantry && (Status = dead || Defense < 3)

At the moment (Vassal 3.1.18) it doesn’t seem to work, at least with that syntax. Regular expressions won’t help, either, I think.

I can get around this problem by splitting it in two different triggers, or using a trigger and a combination of restrict commands etc… but it seems a waste of keystrokes and/or traits.

This is only way how at moment:

Type = Infantry && Status = dead || Type = Infantry && Defense < 3

Thanks for your help.

Can I infer from your example that every || divides properties matches in independently evalued blocks?

Thas is: xxxx && yyyyy && zzzz || 1111 && 2222 || aaaa

is equivalent to (xxxx && yyyy && zzz) || (1111 && 2222) || aaaa ?

mmm yes and no, all depends on how used in the expression

In the original case you gave above and your examples it is a dividing OR but it (should) be possible to make it a substituting OR

example:

Type = Infantry && Status = Dead||Wounded

generally in that case though I go with the single pipe which works also

Is the order of operations published somewhere? Honestly, I have been splitting complex expressions into multiple triggers to be sure the order is explicit, but it would be handy to know how the expressions are actually evaluated.

-Seth

The latest Designer Guide says, on page 15

Is this incorrect?

Based on Tim’s earlier post, the first sentence appears to be incorrect, but not the second. See

https://forum.vassalengine.org/t/trigger-as-listener/3690/6

I will fix the first sentence in the next version of the Guide.

I was able to verify in my own module that, indeed, we are not limited to a single logical comparison operator. However, I didn’t test precedence. For the time being I assume everything is left-to-right, as if there are implicit parentheses like these:

((((value OP value) OP value) OP value) OP value)

But, again, I have not tested this assumption.

A quick look at the PropertiesPieceFilter class indicates that the way this is done in 3.1.18 is:
(1) Split the expression around ||
(2) Split each subexpression around &&
(3) Try to match each subexpression to an OPERAND COMPARATOR OPERAND pattern - succeed (!!) if unable to match this pattern (so, i.e., setting ‘MyProp’ to ‘false’, and entering ‘MyProp’ as the property match expression, will always succeed. For that matter, ‘false’ will always succeed)

This order, with OR operands at the highest level, is borne out in my own brief testing; so, for instance, the following will evaluate to true with MyProp = TRUE:
MyProp = FALSE && MyProp = FALSE || MyProp = TRUE

Cheers,
Seth

Therefore, basically you are saying that the answer to my question above is YES.
I can confirm I have noticed this is how things appear to be working, after the original reply by Tim M.

:slight_smile: