Totaling the Number of Pieces on a Map


I need some help with totaling pieces on a map as I just can’t get it to work. I keep getting the below message

“Set Global Property (Count): Unable to locate Global Property named 0”

Can anyone assist?

Best regards

This from the designer’s guide. … rguide.pdf

Totaling the Number of Pieces on a Map
You can use the Marker Trait in conjunction with the Set Global Properties Trait to sum the number of pieces on a map.

  1. Create a Global Property called PieceTotal.
  2. For the new Global Property, create a Change-Property button called Zero Total that will set PieceTotal to 0 (In Type, choose Set Value Directly).
  3. Create a Marker on each piece you want to add to the count. Name the Marker Count, with a value of 1.
  4. Create a Set Global Property Trait on each piece, which will increment PieceTotal by 1.
  5. Create a Global Key Command called Total Pieces. For Global Key Command, use the keyboard shortcut of the Set Global Property Trait you specified in Step 3, and in Matching Properties, enter Count = 1.
  6. Create a Toolbar Action Button called Count Report. In Display Message, and enter Total Number of Pieces on Map: $PieceTotal$.
  7. Create a Multi-Action Button called Total, and add the Zero Total, Piece Total [typo: should be Total Pieces], and Count Report buttons to it.
    Now, when the Multi-Action Button is clicked, PieceTotal will first be zeroed out (to remove any previous totals), then each piece will add 1 to the PieceTotal, and the Action Button will report the total in the chat window.

Hope that helps.

Thanks RRVS, I’d been following that guide. It was the typo that was tripping me up. All good now.


I have a similar problem. Is there a way to automate this, i. e. to total the values without using buttons? I guess I could trigger an update when moveing a unit to a map, but what if I delete a unit?
The task is: On each (player-owned) Civ Advances map Window I want to total the number of civ points earned so far. Each Civ Advance piece to be placed on that board (they will all be in a specific zone of that board) has a Marker trait with the numeric point value of that piece. I want to see the total of points per player window, for example as a Text Marker on a dummy piece.
This is also a bit different from the original task as each piece has a different value, so I would need to add its Marker trait value instead of “1”, but I guess I could figure that out.
I am sorry if this has been answered before (I am pretty sure someone must have had a similar problem), but my search made no better hit than this thread.

For this multi-board one, I’d try it a bit differently than above. I’d have global properties, making them either private (confined to each board only) or public if you want.

Essentially each player hand map would have a similar ‘ends movement’ gkc added (it’s the last listed property and would be the same exact key for all of the player hand boards). When an applicable piece is moved or sent to a player hand from anywhere other than that player hand, it will add to that player hand’s tally. When a piece is moved or sent away or deleted from a player hand it will subtract from that tally.

The tricky part is the need to short-cut all the global properties and trigger actions traits. You’ll have a distinct global property for each player hand, but will only have one Set Global Property trait handling all of them. You’ll use either the map or board names in each of those global properties. For example for Player Hand 1… let’s say the board is named: PH1. The global property you’ll add for that board will be: PH1CivPoints. However, the one set global property trait (which will be in a prototype you’ll add to all the relevant pieces) will be called: $CurrentBoard$CivPoints. This allows you to greatly streamline the process.

The arrival trigger action would have a matching property of:
CurrentBoard =~ PH1|PH2|PH3 && OldBoard != $CurrentBoard$
It would watch for the map’s gkc, and perform the increment by numeric value total of its marker: $NAMEOFMARKER$ using that single set global property trait named: $CurrentBoard$CivPoints (no matter which board it’s on).

The primary removal trigger action would have a matching property of:
CurrentBoard != $OldBoard$ && OldBoard =~ PH1|PH2|PH3
It would need to add any non player hand map’s end move gkc that might be relevant. For example if the piece is moved from a player hand to the main map.

You’d also want to add a secondary removal trigger action for any delete or send or return to deck actions that won’t trigger the primary removal trigger action trait. For this you’d use a matching property of: CurrentBoard =~ PH1|PH2|PH3; watching for any of those command keys.

This is kind of a quick sketch… it may well have a couple things that need adjusting or haven’t been figured properly. But let me know if it makes any sense as it is.

EDIT: just realized the removal won’t work as is for the primary removal trigger action, as $CurrentBoard$CivPoints would be wrong (if triggered on the main map for example, after leaving PH1)… it would now have to be $OldBoard$CivPoints. You may be able to just add a second Set Global Property trait for that one, adjusting the trigger action to perform it instead. I’d need to give that some thought.

This is marvelous - you never faili to come up with an idea! Thanks a lot, I will try that tomorrow.

Don’t thank me yet. :smiley: Just edited the post above, in case you don’t notice. Good luck with trying it - let me know.

I have a working solution now, based on a mix of both solutions. I was able to leave out some of the details by not providing for some cases that could only come about by user malice and added a “re-calc” button to the player board to repair such situations. I will write a description of what I did some time, but not before the rest of the module is done. Too many things that may change yet… anyway, thanks for the help, even if I did not use all as described it helped me a lot to get a grip on the basic mechanics of VASSAL. There is so much in it that goes straight against my intuitive understanding… mind, I did not say that my intuition is the yardstick to judge VASSAL (or any other software) :slight_smile:.