It might be possible to do something of the sort in a straightforward manner with 3.2.0 by using Calculated properties and the beanshell stuff.
However, sticking with 3.1.x if your cards are in a deck you can first of all turn on performing “counting of regular expressions” on the deck, and export properties like:
1s: CardValue=1
2s: CardValue=2
3s: CardValue=3
…
Then your total will be given by the simple expression: $_1s$ + 2*$_2s$ + 3*$_3s$ + …
For testing purposes you might want to print it out that total. However, you cannot stick the above string in a text label because it won’t work. With 3.2.0 you could define a Calculated Property at this stage - containing that exact expression - and then print that out with a text label. With 3.1.x, instead, define some button with a right/left click command to set up a global property with a bunch of “increment numeric value by” commands, all firing on the same command: the first with $_1s$, the second and third with $_2s$ etc. Then have the text label print out the value of this global property instead.
My reccomendation is to go with Vassal 3.2.0 so that you do not need the “button”, because you
can use a Calculated Property and a text label to show it (and it will dynamically change as expected).
However, if you really want to use 3.1.x (but why?), the “button” we are talking about is simply a piece/unit (even a card) with some left/right click command to fire those “increment numeric values by” commands I discussed before.
For example, it can be a piece with a simple gif/text labels showing “UPDATE DECK TOTAL”, an action button covering the whole of it and firing CTRL-A, and the described set global property trait, with all those “increment numeric values by” commands, all firing on CTRL-A.
You can drop cards into this deck and cards have a Trait named CardValue which is either 1, 2 or 3.
I’ve got an “at start stack” with a single piece that currently just counts the cards. I can see the calculated property option added it to the piece but no matter what i put in the expression field, I just get a red X.
Does this calculated property print itself. if not how do i call it?
Give the Calculated Property a name, like TotalValue, and in the expression field enter:
$_1s$ + 2*$_2s$ + 3*$_3s$
where is of course the name you gave to your deck of cards. Don’t click on “Insert”, just add that string to the expression field and you should get a green checkmark in the end.
Maybe “1s”, “2s” etc are not legit name… then use other strings (e.g. cv1, cv2, cv3…).
Then, add to the single piece a text label to print out $TotalValue$.