One sound for multiple pieces

Hi there;
Hope your weekend is going well. I am attempting to activate a sound (“swish” of door opening in Star Trek) when one or more pieces are moved to the quarters area. The problem is when there are 10 pieces moved - for example - I get sound x10 which sound awful. I tried relaying the Hotkeys from the pieces through 2 Action Buttons hoping that I would get sound x 1 but nah! Any ideas?


When I need to do this, I disable the sound per piece (easy if you’re activating the pieces via a GKC, there’s an option to check - like disabling reporting; thanks @Cattlesquat!).

If you can do that, then your Action Button idea starts to make sense - generate the one sound from there.

Example; these components are defined in sequence (along with others); all fired off by the same Global Hotkey:

Reports card dealing and makes a sound:

Draws actual cards, suppressing their normal report / sound:

Hello Mark;
Thanks for the reply. In my case it is a matter of “lassoing” the pieces I want to send, then a right-click option to Send to Quarters using a Send To Location trait in each piece - no GKC are used… The same command for the STL activates the Hotkey for the Action Button. Not sure how I can utilise a GKC for this, I don’t think it will trigger an Action button.

[Edit] Also, the documentation says “If selected, then any sounds generated by Play Sound traits on any affected pieces will be suppressed during the processing of this Global Key Command.” Does that mean all sound is disabled?

[Edit 2] Yes the suppress feature does disable all sound. Hmmm…also tried using a GKC to activate one individual piece to play the Sound but having multiple Hot Keys firing at once still multiplies the sound effect by the number selected. Bummer!


Yeah, the feature I described isn’t really for select and command-all-at-once.

For your application, a different solution might comprise:

  • a Global Property to track how many pieces have to be processed.

  • the “Selected” property - that would identify selected pieces so that you can count them. Only the first piece to process the command would initialise the Global Property and make a sound.

  • As each piece processes the command, decrement the global property, so that by the end the GP is in a initial state, ready for the next time the select / command action is done.

My bad for not providing more detail about what I am trying to do. I understand how to use the Selected Property to count the number of selected pieces but after that…not so sure. How would I make only the first Piece to use the command issue the sound?

On the piece itself, bundle your actions into two Triggers.

The first trigger should be conditional on the controlling Global Property being equal to zero.
Let’s call that property piecesToCommand. Its initial value should be zero.
The trigger will make the sound and set piecesToCommand to the count of selected pieces.

The second trigger performs the actions that your command needs done on each individual piece.
In addition, this trigger should adjust the Global Property piecesToCommand by -1.

By the end of processing, piecesToCommand should be zero again.

1 Like

OK, yes that makes sense to me, much obliged to you. I will try this some time this week and report back. I was trying to think of a way to use ClickedX and ClickedY because I have to right-click on a piece to bring up the Move To Quarters option but this will be better.

[Edit] Tried this and it works the first time only. Problem being that setting the increment to -1 reduces the GP by -1 in total. So if 10 are selected, the GP becomes 9 instead of 10 + (-1 x 10) and consequently, no sound at all thereafter. I am guessing there is not enough time difference between each increment when applied? Also tried setting the GP to 0 directly and I get the same problem as before where the sound is multiplied by the number selected.

Perhaps I should request a Vassal feature that disables multiple Commands from amplifying a sound.


1 Like

No luck so far resolving this, I tried looping the second trigger until the GP was equal to zero and the effect was much the same as setting the GP to zero directly (awful noise).


I wonder if you are decrementing that Global Property using the Key Command that gets Restricted once the GP is > zero ? That’s why I suggested two triggers - the first should only execute the first time, the second must execute every time and should include the decrementing of the Global Property.

Let me know and if that doesn’t help, export a prototype with the traits in and attach it here.

I’ll reply about that on your specific thread.

Hello Mark;
I have made several attempts trying various things but generally…

The first trigger has the condition that the GP = 0 or in my case: {SelectCount == 0}

  1. Made Sound
  2. Made GP count selected pieces
  3. Activated second trigger

Second trigger has no requirements and

  1. Sends Pieces to Quarters.
  2. Resets count of GP

I was using a Set Global Property in the Piece to make all the adjustments.

Unfortunately I have not kept any of these will have to try and remake the one that worked best and post it here when I can. I have to admit the best one was very close except that the GP would not reset automatically as explained in my earlier post. Thanks for your time and patience, wish I could retire and have more time to spend on Vassal. Attempting this during the week can be a tad frustrating.


See if this demo module helps.

The controlling Global Property is defined in the Map component and I’m using Change-Property elements to set / decrement it. These are actioned by Global Hotkey traits from the pieces.

The demo offers a command on the pieces and also triggers the command when the pieces are moved - just to show that this works too if you need it.

To start a demo, look under the File menu.

The guts are in the Prototype “Demo”.

1 Like

Thanks for doing all this Mark. Sample modules always seem to gel more easily than written explanations for some reason. I will sit down later tonight and look at this properly. A few things I have noticed straight away is

  1. your Trait order which is different to mine which follows the module guide.

  2. You seem to be using the same command to activate both Triggers. I was using the First Trigger to start the second.

  3. Your Count expression is {CountMap("Main Map","{Selected}")} where I was using {CountMap("Main Map","{Selected == \"true\"}")}

Are any of these differences important?

I did try Hotkeys with the Change Property Tool bar initially and had the same problem as with the Set Global Property.


When dealing with a boolean value (such as Selected), {Selected}, {Selected == true}, {Selected == "true"}, and {Selected != "false"} are all functionally identical (except possibly if the property in question is uninitialized).

1 Like

Hello JR
Seeing Selected has to be true in this case, I thought my slightly longer Expression was unnecessary. I try to keep things as simple as possible so the game runs smooth. Both the modules I am working on have some lag issues, especially at Start up.


For me, it’s more to keep the expression uncluttered, perhaps there’s a very marginal performance benefit that might add up overall.

It is important that the property is either true or false for all pieces within the scope of the condition. Don’t forget, Vassal is considering all pieces, until a prior condition has excluded them - so in that CountMap() expression it’s equally significant that Selected is false on the pieces that you haven’t selected. Selected is always true or false so it’s not a problem.

In other situations, the boolean will not be defined on all pieces. e.g. Moved, unless the Mark Moved trait is on the piece. An undefined property returns null and you’ll get Bad Data errors if a condition does not evaluate true or false. An advantage of checking a boolean explicitly - e.g. {Moved == true} - is that it avoids this problem. Should you start using boolean properties a lot, then you might consider defining a default value for them as module Global Properties, that will allow you to use those properties as boolean in any situation.

1 Like

Trait order - the guide is good but the order depends in the end on what Key Command is being actioned. In the case of my example, the important thing is that the one-time Trigger sits above the per-piece Trigger.

Maybe your point 2 is where your error lies. If your first Trigger starts the second Trigger, what happens when that first Trigger has done its initial job of counting the selected pieces? Surely, that first Trigger will - as intended - not action on the others pieces, but that also means the second Trigger won’t either.

1 Like

That would explain why the GP was only depreciating by one. I will find out later after I have a nap. Thanks once again for your assistance and explanations.


Hello Mark;
OK, finally it works. In my Module the Piece already has a lot of Triggers for various things and I was having some trouble but decided to have your 2 Triggers activated by another Trigger to get this to function.

You can see what I did with this sample here. The rest of the Module has been removed to make the Piece easier to find. Any other suggestions are more than welcome of course if you have the time. [Edit] “Send To Quarters” is really for use when the dice are on other parts of the Map but if you select that option while they are in Quarters you will see them move slightly and issue the sound once.


I have been working with vassal for nine months and have not completed a Module yet. No wonder when it takes me a week to get just one thing working and it would not have been possible without your assistance. If at some point I actually have these finished and uploaded to Vassal, I will have to give you and JR Watts a special mention in the credits.