How to report location one hex above $location$?

I am reporting placing a Marker one hex above the game piece:

$PlayerName$ ($PlayerSide$) - $newPieceName$ placed a Mine in $location$

How can I report the hex above the game piece’s location? Game piece is in hex 0902, the marker is placed above it into hex 0901.

How about placing the Report Action trait in the Mine piece ?

If you are using Place Marker to place the Mine then add a Key Command that will immediately execute on it (triggering the report). You can also pass any Dynamic Properties from the parent piece that you might want to use in the Report Action.

Alternatively, a simple way to report from the Parent piece would be to set a Global Property from the Mine piece (triggered on placement) that saves its LocationName, which you can then report from the Parent as part of the placement command.

2 Likes

Thx, but I would need to see an example for the Global Property, as I don’t know the quirks of that (and my syntax is probably wrong as well).

This is the trait in the Probe marker definition:

This is the Place Marker trait of the parent counter (space shp):

This is the Report Action trait in the space ship counter placing the Probe:

Your best option is probably to parse out the coordinates of the current LocationName.

Suppose the hex grid uses a numbering like CCRR where CC is the hex-column, possibly zero-padded, and RR is the zero-padded hex row. Then, an expression like

Integer.parseInt(LocationName.substring(LocationName.startsWith("0")?1:0,2));

gives the column number, and

Integer.parseInt(LocationName.substring(LocationName.substring(2,3).startsWith("0")?3:2,4));

gives the row number.

If the format of the hex coordinates are CCRR where CC are letters and RR are zero-padded numbers, then

LocationName.substring(0,2);

gives the column coordinate.

These calculations can be stored in a Calculated Property, and then you can use those properties to format your report - e.g.,

{BasicName + " in " + LocationName + " places a probe in "+Column+""+(Row+1)}

Yours,
Christian

1 Like

Thx Christian! One small nitpick - when I add the (Row-1) it reports the row without the leading 0 (should be 1504):

Joe (Red) - 1505: BB Indomitable 5 placed a Mine in 154

Unfortunately, I don’t believe BeanShell in VASSAL supports string formatting codes, so the best solution I’m aware of is a bit hacky:

{BasicName + " in " + LocationName + " places a probe in " + Column + "" + (Row + 1 < 10 ? "0" : "") + (Row + 1)}

which prints a leading zero before the Row if it’s less than 10.

2 Likes

Even if whacky, it works, thx!

You can try with String.format, e.g.,

{BasicName + " in " + LocationName + " places a probe in "+String.format("%02d%02d",Column,(Row+1))}

Maybe it works.

Yours,
Christian

1 Like

String.format didn’t work when I tried with VASSAL 3.5.x, but it might have been added since.

For some reason I though this worked, but turns out ti does not…It still reports:

* Joe (Red) - 603: BB Indomitable 3 placed a Seeker 1 in 602

Just realized I did not have the same condition for the Column when it was lower than 10, so I added that and now it all works correctly :slight_smile: