How to fix reporting "moves offboard -> offboard *"

Have you added Grid Numbering to the grid?

I think you need either Grid Numbering, Zones with names, or an Irregular Grid with Region names to have Location Names to report.

Ah! Duh! Maybe that is it!

Gibbs slap me.

Yep that was it!

Thanks, now to fix it.

Vassal allows a lot flexibility and creativity in naming locations. You can use expressions to transform the basic row, column, zone and region names into another scheme of location names. For example I wanted a rectangular grid with location names from 1 to 100. I made the grid fit on its board so that it had 20 columns and five rows. I set the column numbering from 1 to 20 and the row numbering from 0 to 4. I used the expression {($row$*20)+$column$} in the Location format box.

pawnpusher,

Thanks so much for that. I might have to do something like that because the hexgrid is off a bit, the first two rows are okay (the columns running A-G etc. are fine) but after the first two rows things get weird.

So there must be a way for me to use some type of expression but not sure what it is yet.

From your exampled I’d have to figure out how to minus 1 so that the real C57 which is reporting as C-58 is set correctly, and also notice how G55 (real) shows G58 (off by three) and not shown in that screen shot but Q50 (real) is showing Q58 (off by 8!).

So still scratching my head on that one, any ideas?

It looks like your game’s map has a “slanted” grid where the rows (numbered) follow the hex rows which are 30 degrees from horizontal rather the more common horizontal rows which would “zig-zag”. Vassal is set up for the “zig-zag” style rows (or columns). I remember a feature request (and discussion) to number with “slanted” rows like the printing on your game’s map.

Edit: The expressions shouldn’t have the modulo portion, and it looks like the offset needs to be subtracted. See the next post for the updated Location format expression.

You’ll need to convert the column letters to numbers (see: Manipulating Strings or Counting by Letters) and use the Modulo operator to generate an increasing offset to add to (or subtract from) Vassal’s row number. For the row I’m thinking of somethin like: {(“ABCDEFGHIJ”.indexOf($column$)/2)+(“ABCDEFGHIJ”.indexOf($column$)%2)+$row$}. The string “ABCDEFGHIJ” will need to include all the column designators. If the column designators include some two-letter columns like “AA” or “AB” then a different string manipulation will be required. I believe Vassal only uses whole numbers and truncates quotients, discarding the fractions; otherwise the part of the expression “ABCDEFGHIJ”.indexOf($column$) will need to be in a round up or round down function.

So the Location format would be like {$column$+(“ABCDEFGHIJ”.indexOf($column$)/2)+(“ABCDEFGHIJ”.indexOf($column$)%2)+$row$}.

The modulo operation is not needed, and it looks like the offset needs to be subtracted. The expression should be: {$column$+($row$-(“ABCDEFGHIJ”.indexOf($column$)/2))}. You may need to adjust whether the rows start with 1 or zero to get the desired result.

Thanks again!

Not sure how you figured out this stuff lol.

Here is what I used:

{$column$+($row$-("ABCDEFGHIJKLMNOPQRSTUVWXYZAABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX".indexOf($column$)/2))}

But the columns are still off, the rows seem fine, and the first two rows are good, but then they start to go off by 1 for the next two rows, and then off by 2, for the following rows and then off by 3 for the next two rows.

Finally being off by 24 o the last row.

image

Trying to make sense of this…

The grid numbers Vassal displays (in blue in you screen shots) are $column$+“-”+$row$. Vassal does not display the result of your location format expression. You need to move a counter to see the modified location format in the chat.

Yeah they still out of whack:

Hmmm!

So -(“ABCDEFGHIJKLMNOPQRSTUVWXYZAABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX”.indexOf($column$)/2)
seems to adding to the row number rather than subtracting from it. Maybe try changing the “-” to a “+”.

By goll that worked!

Your my hero!

I’ll add you to the credits lol

Thanks so much!

Man that was a head scratcher, most map suse the 0101 type of hex grids and those are easy to figure out.

Again, thanks so much!

Don

Okay that worked for A-Z but the AA-XX are messed up lol

So how would you fix that?

Crazy hex grids from AH…lol

I had help on the Vassal Discord. I was wanting a different hex designation. For a hex grid like yours, flat on top (vs. pointy on top), I wanted straight rows that skipped every other column rather than zig-zagging. This would split one row into two rows.

So referring to your screen shots: The top would be A58, C58, E58, G58…
The next row down would be B57, D57, F57, H57…
The next row down would be A56, C56, E56, G56…
The next row down would be B55, D55, F55, H55…

Ah I see what you mean. Yes helps is most welcome on some of the aspects of VASSAL.

Any idea why the AA-ZZ hex rows are off?

Is there a way to add strings like:

‘AA’,‘BB’,‘CC’,?

I was never that good at regex stuff lol.

OK.

We need for the offset to change by one for every two columns we move over.

The indexOf method returns a number representing the position of the first character of one string in another string. See: https://vassalengine.org/doc/latest/ReferenceManual/ExpressionString.html#top

Our expression works when the column designators are just one letter but messes up when the designators change to two letters. I think the easiest fix is adjust the column designator reference string so that every column is represented by two characters, by inserting a space in front of every single character column designator, and increase the division from by two to by four. The resulting expression would look like:

{$column$+($row$+(" A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX".indexOf($column$)/4))}

Wait, I need to fix the expression.

Let’s try adding the spaces after the single character column designators rather than in front of them:

{$column$+($row$+(“A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX”.indexOf($column$)/4))}

Originally I tried your second expression and that was doing blanks. So I went back to the first one and it works!

Here is what worked for this module:

{$column$+($row$+(" A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX".indexOf($column$)/4))}

Many many thanks!

Brillant!

I can’t wait to share the module when I am finished tweaking it, this has been a very big help!

Don

1 Like

Hi Don,

Since the grid-numbering is oblique, you may want to consider to use a custom grid numbering, for example ObliqueHexNumbering (compiled class file, built against VASSAL 3.6.7). See also this issue and this thread.

Right click your Hex grid and say something like Add custom class and select the .class file.

This custom element has a number of benefits over calculating the coordinates elsewhere

  • All places that uses the hex grid numbering will use the same oblique grid numbering
  • That means that you do not have to copy complex BeanShell expression all over the module
  • BeanShell expression are relatively slow, since an interpreter has to parse the code and execute it. The Java class does that in byte-compiled code.

Note, since the source code is available one can always rebuild or update the .class file for newer VASSAL core library, so that you don’t get deprecation warnings

Yours,
Christian