Hide all Layers


I’m struggling with a bit of functionality… This relates to the Fields of Fire combined volumes mod.

I have counters, and each counter may have a number of layers applied to it to indicate experience, ammunition etc. I’m trying to make a toggle button that basically hides all the layers on all counters (but remembers their values so I can switch them back on again), to just show the ‘clean’ base counter.

I’ve found the Game Piece Layers trait, and added the layer names to that etc, but all I’ve managed to get it to do is either nothing, or hide the entire counter that has that layer on it?

Obviously missing something!! :smiley:

Appreciate any help… Thanks


Hi Colin - you may have been misled by some parallel and confusing use of terminology in Vassal.

  1. A Game Piece Layer is a layer within which pieces sit, depending on what the value is of a property that is named in the Game Piece Layer within the map that the piece is on. Typically a piece will simply use a Marker trait with that property name and the name of the layer that the piece is supposed to be on.
    As you have found, there is a control that you can define in the Game Piece Layer component that allows you to toggle the display of those pieces in a layer or layers.

  2. The Layer trait on a piece is just an image that displays with the piece. It is entirely unconnected to the Game Piece Layer, and just follows whatever the overall piece does in that regard. The ability to toggle display of Layers on a piece depends on you manipulating the definition of the Layer trait. I will make a suggestion in a further post, but essentially I think that you will likely need to use the “Layer follows Expression” to achieve what you want.

1 Like

A couple of methods come to mind. I mentioned (2 below) “Levels follow expression value”, which I prefer myself but (1) may be more familiar as it uses Key Commands on the Layer trait, which is the default when you add that trait to a piece.

If you are using <layer_name>_ properties in the module then be cautious of changing such a layer for display purposes. You should review how you use those properties and adapt this method or other part of your module accordingly. See bottom of the Layer documentation page about these properties.

1) Toggling Layer display by using the layer Activate Key Command.
The Layer trait provides an Action option to Activate / Deactivate a layer. You need to uncheck “Always active?” to see this. In the following example, I’ve assumed that you don’t want players to see the Activate command on the pieces.

On re-activating the Level is restored to what it was before. The effect on de-activating a Layer on <layer_name>_ properties is that <layer_name>_Active becomes false and <layer_name>_Level is set to the negative of the Level. The other properties become blank.

I am pretty sure that a layer is Active by default; so we just need to provide that toggle button. This would be a Global Key Command that finds all the pieces that you want to toggle layers on. For example, this Map GKC would find all the pieces with an experience layer on the map and give them the activate command shown on the previous example;

You could generalise this to send the toggleDisplay command to more pieces, if some pieces don’t have the experience layer. You just need to have some criteria like a Marker on all pieces that you wish to send the GKC to. The Hotkey is optional; in this example pressing F6 is an alternative to clicking on the button.

2) Toggling layer display by using Levels follow Expression Values field
This method that doesn’t require GKCs and may be quicker. It is a little more fiddly to set up if you are not already using it to determine the Layer levels. Another advantage is that it is possible to use this method in combination with Global Option preferences such that displaying the layers becomes player-specific (just like Game Piece Layers is).

If you have not used this field before, then you will need to start by moving your current layer setting method from Key Commands in the Layer trait into a Dynamic Property that sets the Layer Level. The Dynamic Property then goes into the “Levels follow expression value” field. Typically such layers are always active (we’ll be adding a blank layer anyway, if you currently have the layer sometimes inactive.
Here is an example DP setup to replace the Layer controls in the previous example. Notice that the minimum and maximum are set to mirror the available layers that you wish to display.

Here is what the Layer trait looks like, notice I’ve added a 5th blank layer. That is not set by the DP in the example, but we’ll use it in the next step.

How to apply a toggle button when using “Levels follow Expression Values”: this can be done using a Global Property with a Change-Property attribute added to it, that itself it controlled by a Button and/or Hotkey. If that GP is called “LayersOn” then the example expression should look like this:
{LayersOn ? experienceSetting: 5}

The Global Property would be defined at Map level (or could be Module level if you have multiple maps to which this function will apply).

Add a Change-Property attribute to the GP that looks like this:

The “!” before LayersOn in the New Value field simply toggles the value from true to false and back, so toggling the expression in the Layer trait between the blank image and the display image.

Providing Layer display as a per-user option.
To achieve this, replace the Global Property with a Global Option checkbox property. You can still control this by a button and/or hotkey but it requires using a control piece and a Global Key Command to perform the toggle. For more information see this tutorial.

Hope this helps. Feel free to ask questions or point out errors.


That’s great Mark - thank you for taking the time… I’ll give them a go and report back! :slight_smile:

1 Like

So your first method is doing exactly what I wanted it to :slight_smile: … except… :wink: the layers are defaulting as ‘off’ at the start. Is there any way to make the layers all active when the module is started, without needing the toggle button pressing once to bring them on?

EDIT - Actually, looks like 2) might do that? I’ll try that one :slight_smile:

Yes, it will allow you to set the initial display condition and has more potential.

If you want to stick with Method (1), you could try the following:-

  1. Add a temporary or hidden command that allows you to Activate pieces individually (e.g. a Trigger than calls the toggleDisplay command). You could try just putting a Menu command temporarily on the Layer traits, but this may not work, as Layers might reset when you change the Menu command back to blank (I’m not sure).

  2. Now go through all pieces in your palette, decks or At-Start Stacks to toggle the layer Active. I think this will work; I have certainly used other commands in this way, but not all commands make sense on a palette, so some definitely are disabled.

  3. For existing scenarios, if you have them, go through them individually - use the button to change all pieces on the map and then save and replace the scenario back into the module.

There are other ways, involving configuring existing pieces using a Startup GKC and as pieces move onto the map. However, it will start to get more complicated and the last thing you want is pieces in a different state at the same time.

If this sounds like too much work, then Method (2) should be better.

Unless, someone else has a neater idea for setting the starting Layer state “Active”.

Thanks Mark - really appreciate it :slight_smile:

1 Like