Counting a variable number of pieces in a defined zone

Hello,

I am pretty new to Vassal, so my question may seem obvious, but the problem is quite tough for me. I am currently developping a module in which tokens have to be counted in several zones. I would like to display the number of these tokens, sorted by zone and owner (each token is owned by a player side), in a separate window. The point is that every solution I have found for now in this forum concerns numbers of tokens that can only increase (which could be done using global properties, I think), whereas I would like to be able to refresh this value even if some tokens are moved to another region (which can often happen).

My map is a multi-zone grid defined manually and my tokens are (for the moment) single pieces. Is there a way to count in a variable (maybe linked to the zone?) the number of single pieces containing a certain type? I have seen several times in different modules counters displayed in text labels, but I was never able to find where the variables where defined (for example in the Battlestar Galactica module, which is the one I know best - even if far from perfectly -)

Thanks in advance and sorry again if that may seem obvious to more experienced developpers :slight_smile:

Hi,

I don’t have a specific solution for you. However, there is a design principle that I follow that may help.

Sometimes, when I convert a game to a module, I don’t necessarily recreate every game element in Vassal exactly as it is in the game. Things like counters that are used as some sort of scoring or bidding mechanism can be more easily implemented as Global variables with buttons to modify the values.

Have a think about whether you actually need counter pieces that have to be moved into the zone, or whether it could be done with a different mechanic.

Regards,
Brent.

*********** REPLY SEPARATOR ***********

On 14/07/2011 at 3:36 PM Ektelioth wrote:

Hello,

I am pretty new to Vassal, so my question may seem obvious, but the
problem is quite tough for me. I am currently developping a module in
which tokens have to be counted in several zones. I would like to
display the number of these tokens, sorted by zone and owner (each token
is owned by a player side), in a separate window. The point is that
every solution I have found for now in this forum concerns numbers of
tokens that can only increase (which could be done using global
properties, I think), whereas I would like to be able to refresh this
value even if some tokens are moved to another region (which can often
happen).

My map is a multi-zone grid defined manually and my tokens are (for the
moment) single pieces. Is there a way to count in a variable (maybe
linked to the zone?) the number of single pieces containing a certain
type? I have seen several times in different modules counters displayed
in text labels, but I was never able to find where the variables where
defined (for example in the Battlestar Galactica module, which is the
one I know best - even if far from perfectly -)

Thanks in advance and sorry again if that may seem obvious to more
experienced developpers :slight_smile:

First, thanks for the advice! True, the only thing I need is some way to count these points, but as you say, using some global variables and +/- buttons linked to the zones is easier to code and I wanted to improve my knowledge of Vassal :slight_smile: Moreover, the feeling of the games is always better if the way used to play with Vassal is close to the real one, which is another reason why I wanted to do it that way :smiley:

But to my mind the most obvious reason is that tokens give information just by looking at them directly, and my counting problem is only to have a more detailed breakdown of the score in each zone (when you have 4 counters one one side, 3 on the other, 5 in the last and that you have to count the same sort of result in each zone, it is sometimes easier to look at a window than to move each token to count them).

Once again, thanks for the idea ;)