# Text labels hidden from opposition?

**URL:** <https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933>\
**Category:** Module Design\
**Created:** [November 15, 2024, 8:18pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933 "2024-11-15T20:18:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pixelpshr](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/pixelpshr/32/243_2.png) [@pixelpshr](https://forum.vassalengine.org/u/pixelpshr)\
**Post date:** [November 15, 2024, 8:18pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/1 "2024-11-15T20:18:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JoelCFC25](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/joelcfc25/32/2687_2.png) [@JoelCFC25](https://forum.vassalengine.org/u/JoelCFC25)\
**Post date:** [November 15, 2024, 10:13pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/2 "2024-11-15T22:13:02Z")

</div>

Sure. Use a ternary expression [as found in this thread from last spring](https://forum.vassalengine.org/t/want-to-hide-text-label-from-one-side-or-other/79347).

---

<div class="post-metadata">

**Author:** ![pixelpshr](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/pixelpshr/32/243_2.png) [@pixelpshr](https://forum.vassalengine.org/u/pixelpshr)\
**Post date:** [November 15, 2024, 11:23pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/3 "2024-11-15T23:23:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pixelpshr](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/pixelpshr/32/243_2.png) [@pixelpshr](https://forum.vassalengine.org/u/pixelpshr)\
**Post date:** [November 19, 2024, 7:19pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/4 "2024-11-19T19:19:19Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![cholmcc](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/cholmcc/32/8319_2.png) [@cholmcc](https://forum.vassalengine.org/u/cholmcc)\
**Post date:** [November 19, 2024, 7:43pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/5 "2024-11-19T19:43:36Z")

</div>

> [@pixelpshr](#):
>
> Can I use this:  
> {PlayerSide != “Blue\*” ? localHull+“/10” : “”}

Use the `String.contains` method like

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

```

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

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

```

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

```auto
{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

```auto
{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_

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

```

and then do

```auto
{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_

---

<div class="post-metadata">

**Author:** ![JoelCFC25](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/joelcfc25/32/2687_2.png) [@JoelCFC25](https://forum.vassalengine.org/u/JoelCFC25)\
**Post date:** [November 19, 2024, 7:58pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/6 "2024-11-19T19:58:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cholmcc](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/cholmcc/32/8319_2.png) [@cholmcc](https://forum.vassalengine.org/u/cholmcc)\
**Post date:** [November 19, 2024, 8:05pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/7 "2024-11-19T20:05:32Z")

</div>

> [@JoelCFC25](#):
>
> 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_

---

<div class="post-metadata">

**Author:** ![pixelpshr](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/pixelpshr/32/243_2.png) [@pixelpshr](https://forum.vassalengine.org/u/pixelpshr)\
**Post date:** [November 19, 2024, 8:09pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/8 "2024-11-19T20:09:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JoelCFC25](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/joelcfc25/32/2687_2.png) [@JoelCFC25](https://forum.vassalengine.org/u/JoelCFC25)\
**Post date:** [November 19, 2024, 8:33pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/9 "2024-11-19T20:33:37Z")

</div>

> [@cholmcc](#):
>
> Milage may vary - but I’ve not seen that.

Just so other readers know I’m not telling tales–[a form of confirmation](https://forum.vassalengine.org/t/calculated-property-vs-global-key-command/10823/5). 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.

---

<div class="post-metadata">

**Author:** ![pixelpshr](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/pixelpshr/32/243_2.png) [@pixelpshr](https://forum.vassalengine.org/u/pixelpshr)\
**Post date:** [November 20, 2024, 10:20pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/10 "2024-11-20T22:20:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JoelCFC25](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/joelcfc25/32/2687_2.png) [@JoelCFC25](https://forum.vassalengine.org/u/JoelCFC25)\
**Post date:** [November 20, 2024, 10:36pm UTC](https://forum.vassalengine.org/t/text-labels-hidden-from-opposition/83933/11 "2024-11-20T22:36:58Z")

</div>

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.
