Layer toggle headaches

My units have several layer “flags” that can be toggled on/off; for this example let’s talk about “Fly CAP”, which is used to graphically flag an air unit as flying a CAP mission.

It is simple enough to create the layer and give it a menu item and key command (CTRL F) to activate when needed. This works fine for a single unit, as pressing CTRL F will toggle it on and off as desired. However, if you fly this unit to another hex and stack it with another air unit which is NOT flying a CAP mission, you run into a stack toggle problem.

Stack example:
Air Unit A is Fly CAP
Air Unit B is not flying CAP
Click on the stack with the intention of toggling CAP off
Press CTRL F
Air Unit A is now not flying CAP
Air Unit B is now set to Fly CAP

Of course the player can double-click the stack then select the unit that he wants to toggle off CAP, but as the stack gets bigger and potentially several units are in varying states of layer activation, this becomes cumbersome.

I did come up with one really rough workaround, which was to create two identical image Levels inside the CAP Layer :

  • The CAP layer is Always Active, but the first level is blank (so base state is not flying CAP)
  • CTRL F steps through the Levels, so if your stack has a mix of units at Layers Level 1 and Level 2, they end up at Level 2 and Level 3 which are both the same graphic for CAP.
  • ALT F is used to “Reset to level 1”, which drops any Layer Level greater than 1 down to Level 1, thus clearing the CAP flag.

Is there a cleaner way to do this? It seems kludgy, and I feel like I must be missing something; surely Vassal has a method to hard-deactivate a layer, not just toggle the state from active/inactive?

I would probably just leave it alone, but now I’m looking for a way to make a trigger or key to reset all Flags when a unit lands on the Dead Unit map. I was hoping to read the Layer property CAP_Active=true, but to get the stack behavior I want my layers are always Active.

I hope that all makes sense to someone :slight_smile:

My instinct (without testing this to be sure) is that you’d want to “wrap” things in a Trigger–take the keystrokes you are currently exposing to the user with menu text that are the controls of the Layer trait itself and put them on a Trigger that acts on the Layer trait with some logic.

Take the activate/deactivate Layer control and give it a named keystroke (pretend for a moment it’s ToggleCAP) and NO menu text. Then have two Triggers:

CTRL F with menu text “Fly CAP” and a property match expression of CAP_Active = false that sends the ToggleCAP named keystroke. This will toggle on the layer, but only be applied to those pieces where the layer is currently inactive.

ALT F with menu text “Clear CAP” and a property match expression of CAP_Active = true that sends the ToggleCAP named keystroke. This will toggle off the layer, but only be applied to those pieces where the layer is currently active.

I might try having a layer that’s “always active” but has two “levels”, one of which is invisible? And then you can have level “follow expression value” so it could track to a dynamic property or something like that which you have more control of (easier to set the exact value you want instead of toggle)

Thanks for the ideas, will see what I can work out.