Automatically assign numerical IDs to counters of the same type

The linked demo shows how Vassal can be made to automatically assign numerical IDs to counters of the same type, using an integer sequence whilst allowing other counter types to use a different sequence.

For instance, the user may have two counter types: Fighter and Cruiser. If you play 2 fighters, they are labeled 1, 2, 3. Cruisers would get their own numbering (1, 2, 3, etc.), so one can distinguish identical unit types from one another.

The demo offers two pieces, “A” and “B”. They share the prototype “Indexer” which maintains an index (two Global Properties) for each piece type and applies the next sequence number to each new piece as it is created.

The creation of a piece is detected via a Map Movement Key Command, which must be configured on each map where the pieces are allowed to be created. Optionally, piece numbering can be extended to cloned pieces as well.

If you simply require a unique identifier for each piece in a game, consider using the Vassal built-in property UniqueID instead. Details on this page.

pieceNumberingDemo.zip (link downloads the demo from GitHub)