Text labels hidden from opposition?

Is there a way to make a text label that is always hidden from the opposing side? I have text labels that are invisible when the game piece is invisible or flipped, but they are visible when the game piece is visible and unflipped.
Or is there a better way to add private information to a piece?
Is this instance, I have pieces that might be real, spoof, or decoy. I’d like to let the opposition see the piece but not be able to tell if it is a spoof/decoy until they beat a perception roll. Then they should be able to see the label.

Sure. Use a ternary expression as found in this thread from last spring.

1 Like

It’s funny that this didn’t turn up in my search of the forum archive. Thanks!

That gets me very close to what I need. The one problem I’ll have is that I have many Red and Blue players. Is there a way to use wildcards in the Text Label function?

Instead of this:
{PlayerSide != “Entente” ? localHull+“/10” : “”}
Can I use this:
{PlayerSide != “Blue*” ? localHull+“/10” : “”}

Otherwise I will need to list 25 individual players in that logical test.

Thanks!

Use the String.contains method like

{PlayerSide.contains("Blue") ? localHull+"/10":""}

or - if the sub-string Blue can be in non-blue player names - String.startsWith

{PlayerSide.startsWith("Blue") ? localHull+"/10" : ""}

There’s also the method String.matches for more generic regular expression matches - e.g.,

{PlayerSide.matches("^Blue.*")?....}

which does the same as String.startsWith. If you want to make the match case-insensitive, convert the string to lower-case before comparing

{PlayerSide.toLowerCase().startsWith("blue")? ...}

BTW, perhaps another way, which is slightly more flexible and requires less maintenance is to add a Prototype - say “BlueOnly prototype” and “RedOnly prototype”, to all blue and red pieces, respectively, with a CalculatedPropertyTrait a la

name = PlayerOwns
expression = {{PlayerSide.startsWith("Blue")}} // Or "Red" for red pieces

and then do

{PlayerOwns ? localHull+"/10" : ""}

in your LabelTrait and similar for other traits that may need to hide information from opposing players. That also means that your LabelTrait - presumably in a Prototype - is independent of the actual side and can be reused over more pieces.

Yours,
Christian

I would avoid using a Calculated Property directly in a Text Label. Even just a handful of them start to make performance bog down to a crawl and introduce very noticeable map redrawing delays.

Milage may vary - but I’ve not seen that.

CalculatedPropertyTrait is very nifty for doing calculations that depends on external things where it will be harder to get a DynamicPropertyTrait triggered.

For those that are wondering - the expression of a CalculatedPropertyTrait is generally evaluated every time its value is referenced in some other expression. The expressions of DynamicPropertyTrait are only evaluated when the configured key or key-command is passed.

Yours,
Christian

Thanks everyone! I’ll let you know how it goes. (With hundreds of game pieces and 50 or more players)

1 Like

Just so other readers know I’m not telling tales–a form of confirmation. I have direct experience with drawing lag introduced by as few as 3 omnipresent pieces with Text Labels displaying a Calculated Property containing only very mild complexity. Removing the direct reference to the CP made drawing performance return to normal immediately.

It’s worth giving it a shot–if you get no problems, great! Just don’t expect it to be consequence-free.

In an effort to limit the amount of damage the players can do, I wanted to set the text label from a Dynamic Property, giving a list of 3 options (Real, Decoy, Spoof). But I’m having trouble getting the Property Name (Hidden-Text) into the Text Label field. I’ve tried several different approaches, but they all end up saying something like, “Module Error: potential infinite loop defining {Hidden-Text}”
Is this something that should be possible?

I would avoid having hyphens in property names if you can at all help it. It’ll probably be interpreted as a minus and attempt subtraction. Make the name of the property HiddenText and see what happens.