Layer Level Follows Expression

I want to hide the number of steps on a counter by setting the level of a layer based on the Player Side. When the Player Side is Axis a purple square will cover the number of steps and when the Player Side is US it will not be covered. Looking like this:

[attachment=1]Hide-Steps-Example.png[/attachment]

Level 1 is just blank and I set the Level follows expression like this:

[attachment=0]Hide-Steps-Example-2.png[/attachment]

But it’s not working. Do I have the expression wrong? Some other mistake?

Thanks,

Jim

That would have the counter in different states for different people. I don’t think Vassal allows for that kind of behavior (I’d be happy to be wrong, it’d allow some trickery in a module of mine). i.e., I don’t think PlayerSide is a valid variable for that trait (meant for use with triggers and the like).

Though I am wondering if you could do what you want with a Mask trait…

To add, you’re currently adding an integer to something that evaluates to “true” or “false”…i.e, you’re not getting an integer result, which you need for layer follows expression.

If your level 1 = 1, then how about: {playerSide==“Axis” ? 1 : 2}

But I think Rindis is right, the idea of a layer displaying as different things based on player side isn’t something I would expect to work.

Personally, I’ve had problems putting actual calculations in the “Follow Expression” field, so I’ve resorted to adding a Calculated Property and just putting the CP in that field. And Joel’s formula is right, although I’ve been using “PlayerSide” rather than “playerSide”–not sure if that makes any difference.

My concern with tying a layer to PlayerSide is that I believe it will change based on which player last interacted with the game (that is the current “PlayerSide”), rather than which player is looking at the piece, which I assume is what you want. I think you need to use a Mask if you want the piece to look different to the owner as compared to other players (it doesn’t have to actually conceal the piece, despite the name of the trait, IIRC).

Unfortunately, after looking at the Mask trait, it would require you to “reverse” your current set up–you can specify an image to display on top of the main image for the owner, but not for other players, so you would have to create an image that is a copy of your base image but with the number of steps obscured, and assign that as the “view when masked”, then create another image which is transparent except for the number of steps, and set the “Display style” to “Use image”, with this mostly transparent image selected (so the owner can see the number of steps).

On 2nd thought, the “Use image” could just be set to the original image, as it would then completely hide the altered image with the obscured number of steps.

‘playerSide’ is the correct name for the property as per the manual, however, at one release, PlayerSide was added as an (undocumented) synonym, so works as well.

Using a Beanshell expression as a ‘Follow Expression’ value should work, however, this will cause performance issues that will become apparent as you have more and more counters on the screen using this expression. Using a Calculated Property is neater, but will still cause the performance issues.

For best performance, use a Dynamic Property and just update the Dynamic Property as required. However, this is not always possible and you may need to use an expression. That’s fine as long as you are aware of the implications.

Other than that, your usage of playerSide in the Follow Expression of a Layer field does appear to work (with the corrected expression of something like {playerSide==“Axis” ? 1 : 2}) and seems to work as a Dodgy Brothers ™ Mask-like trait. Be careful with what happens when one of the players changes to Observer status though, this will probably give them access to the layer you are trying to hide. A Mask handles this. You would need to code this into your expression (which adds to the performance issues).

Regards,
Brent.

Thanks, Brent. That worked.