I noticed some strange behavior involving LocationName in a hex grid, which only shows up in the case where the hex code starts with a 0, like 0502.
The condition Prop = $ LocationName $, where Prop is the name of a dynamic or global property, returns the value 502 and not 0502, which results in errors in executing commands.
Is it possible to solve this problem in a simple way?
Iām wondering if writing your expression as Prop = ā$ LocationName $ā will solve the problem. Iām thinking that since the location name is composed of numerals, the value is interpreted as numeric rather than as a string of characters.
I believe
{Prop == LocationName.format("%04d")}
should also workā¦this tells Java/Beanshell to format the string as a decimal, left-padded with zeros to a length of 4.
In the meantime, I solved the problem, albeit in a somewhat artificial way.
I noticed by chance that while LocationName is a string variable, when loading the contents of that variable of another variable, for example: CurrentHex = $ LocationName $, where CurrentHex is a global variable, even not defined as numeric, Vassal transforms the string into a number: if the LocationName value is the string ā0703ā, CurrentHex has the numeric value 703.
Not sure if this is a bug or a Vassal feature.
In any case, it was sufficient to insert the condition: CurrentHex / 1000 = 0 in a trigger, in order to then be able to manage separately all the cases in which the first character of the string contained in LocationName is a zero.
I also tried the solution proposed by Jrwatts, which looked very promising, but I get āexpression evalutation errorā.