Help needed designing a Counter Builder

I’m a bit of a VASSAL beginner so hopefully what I’m trying to do is well understood and easy.

I want to set up a Counter Builder which can have three labels each of which can be set to different values.

I’ve managed to do this using a Prototype including ‘Text Labels’ to size and position each of the labels and then ‘Dynamic Property’ to set the range and allow the labels to be changed. All good, but simple numerical ranges: 0 - 3 or 0 - 5

So, I can have 1 1 1 or 1 2 1 or 3 5 3 across the bottom of counters. All three labels can be independantly set but limited to numbers. I want to select from text strings so I get, for example SML GRN RM instead of 1 1 1 or STD TRN SB instead of 2 2 2

Label 1: SMl, STD or LRG instead of 1 2 3
Label 2: GRN, TRN, VET, Elite instead of 1 2 3 4
Label 3: RM, SB, RC iinstead of 1 2 3

Can someone please point me towards the solution.

My first thought is to use a Calculated Property to convert those numbers to text: for example, if label 1 is stored in a property called “Size”, you could create a CP called SizeText with the expression: (Size == 1 ? "SML" : Size == 2 ? "STD" : "LRG") (this code assumes that if it isn’t 1 or 2, it must be 3), then change your text label to display SizeText instead of Size.

Thanks jrwatts. A really helpful reply.

I managed to get it going uisng Dynamic Property and the Prompt user to select from list option. I have looked at the Calculated Property option but have never found a simple guide to the syntax. I’m so old I still think in Basic terms like IF… THEN… OR. I can translate your example in these terms.

Would be good to find a guide to Vassel Syntax.

1 Like

Calculated Properties use Beanshell Expressions; many other traits can optionally use Beanshell Expressions, if they enclose them in curly braces {}–if you see a button with a calculator icon to the right of the field (with the popup label “Expression Builder”), you can use Beanshell. Beanshell Expressions use a subset of Java, which is based on C. The Expression Builder has an “Insert” button which will help you build the expression you want.

My code snippet above uses the C/Java ternary operator ?:, which is a shorthand for if-then-else. You could read it as "If Size is 1, then “SML” else if Size is 2, then “STD”, else “LRG”.