Text Label Bug

I have game pieces with an editable text label added. When editing, the entry of “000” (three zeros) results in displaying ONLY a single “0”. If a letter is added first, no problem with the next zero’s.

This is important for me to directly replicate a wargame created by the UK Defense Ministry.

For now, I am using the letter “O” at the beginning, but it just doesn’t look correct.


[attachment=0]Annotation 2020-09-12 200200.png[/attachment]Hello cpangracs,

I checked into the vassal code why this occurs, and the answer is that it is not techincally a bug.

Text Labels are interpreted as follows:

  1. Check if the entered label is a Beanshell expression, then evaluate it as such.
  2. Check if the entered label can be interpreted as is an integer.
  3. Check if the entered label is a NonBeanshell expression (a string starting with $
  4. If none worked, treat the label as a string.

I do not think this behaviour can be changed. I suggest a workaround:
Create a Marker trait with the lable you want to display ex: Marker “mylabel” value “000”
Put as label string “$mylabel$”.
I tested it and it works. See the attached module.

Alternatively, I believe it should be possible to apply the “%03d” format to the string to be displayed, but my Beanshell/Java is a bit too weak to figure out the exact syntax. Assuming the value to be displayed is stored in the Dynamic (or Global) Property “value”, something like {String.format("%03d",value)} as the text to display should work (assuming I’m correct and you can use Beanshell expressions for text labels).

I have just done a quick test and if a global property TEST contains the value 000 then putting $TEST$ in the label correctly displays 000, so displaying values from properties is not a problem.

The problem is occurring when the 000 is entered directly into the label format. If you just want to directly display the String 000 you can use {“000”} as the label text.

Understand all of the above, but I do need it to be in the editable text on a piece, and not a static marker or trait.I worked around it, so no worries.