Reset a layer on multiple counters with a button push


Does anyone know how to clear all instances of a particular layer with a press on a ‘cleanup’ type button on the interface at the top of VASSAL?

My situation is this:

I am editing the Fields of Fire 2 module. In the Boardgame version when a unit moves it is marked with an ‘Exposed’ counter that stays until the end of the current turn, whereupon all units marked as such have them taken away.

To cut down on the number of counters on the VASSAL mod I have made a layer that adds a graphic for ‘Exposed’ on the bottom of the counter (troop counter is 75x75 pixels, the layer is 20x75 and placed at -40, so it ‘attaches’ to the bottom). I’ve done this as it then clearly tags the unit as Exposed, and works when the stack is examined with a mouse hover etc (text labels don’t show in hovers?)

However, how do I get all units marked with these layers to have them cleared at the end of a turn? The module currently does this by the Exposed status being a counter, with a trait ‘cleanup = True’ on it, that is then triggered with a button. But I can’t work out how to reset all counters with my Exposed layer on… Is it possible?

Hope the above makes sense! :slight_smile:



Sure, that should be pretty straightforward. Review the documentation of the Layer trait and you’ll see how an active layer can be identified by a property. When you despatch a Global Key Command to all pieces, you can use this in the property match expression of the GKC so that only pieces that have this layer active receive the command to turn the layer off.

Struggling Joel :frowning:

So I have a Prototype attached to my units that adds the layer EXPOSED

EXPOSED has two levels - a blank image (ie no overlay) and level 2 is an image that is appended below the unit counter.

The prototype also includes a Dynamic Property called ExposedYES; initial value 1, is numeric, and has a range of 0 to 1.

I think this should ‘tag’ any of my unit counters with an Exposed marker?

Then I have my Global Key Command looking for the expression ExposedYES=1 and giving a Ctrl-X order to remove the Exposed layer.

But when I fire it, it selects all units and basically toggles the exposed layer on if it wasn’t there before, and off if it was… Argghhh!

I’ve tried following the wiki, but I’m obviously missing a step? Any hints?! :smiley:


Anyone know of a mod that does similar (uses a button to remove layers from All Units, rather than remove a counter) that I could have a look at how to do it please? I’m still struggling :frowning:

Oh, and by the way, I’ve tried a different approach too - defining a keystroke to the Reset for the layer, but I now also can’t work out how to select EVERY counter on the board and then apply that keystroke as part of the cleanup process… :frowning:

Sorted it now… I was trying to be too clever with Expressions!