# How to re-randomise a layer until != a specific layer?

**URL:** <https://forum.vassalengine.org/t/how-to-re-randomise-a-layer-until-a-specific-layer/5969>\
**Category:** Module Design\
**Created:** [May 8, 2013, 1:30pm UTC](https://forum.vassalengine.org/t/how-to-re-randomise-a-layer-until-a-specific-layer/5969 "2013-05-08T13:30:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benkyo](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/benkyo/32/3289_2.png) [@Benkyo](https://forum.vassalengine.org/u/Benkyo)\
**Post date:** [May 8, 2013, 1:30pm UTC](https://forum.vassalengine.org/t/how-to-re-randomise-a-layer-until-a-specific-layer/5969/1 "2013-05-08T13:30:45Z")

</div>

So I have this object with 5 layers.

An action button with keypress A  
A trigger for key A with {_\_Active==false} causes 2 key presses - B to activate the layer, C to randomise it.  
Various other triggers all activate depending on the layer result, using {_\_Level==1} {\*\_Level==2} triggers etc. and that all works fine.

All I want to do is have another trigger that re-randomizes the layer if the first button press results in a layer that matches the active PlayerSide - each layer represents a character and if the character is the same as the player it is no good.

However, every combination triggers and calculated properties using GetProperty(PlayerSide) and _\_Level==_ triggers that I’ve tried either results in infinite loops or nothing happening and I’m confused. Specifically, triggers using the condition {GetProperty(PlayerSide)==_&&_\_Level==\*} seem to always activate, regardless of the initial layer result.

Say the PlayerSide is Adam, the layer property is called player and the layer that is also Adam is Level 1:  
A trigger that performs key press C that only activates when properties match {GetProperty(PlayerSide)==Adam&&player\_Level==1} and key C is pressed (ie the Action button is pressed) surely should activate only when the PlayerSide is Adam and and Level 1 is randomised?

Any help?

---

<div class="post-metadata">

**Author:** ![downs](https://forum.vassalengine.org/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@downs](https://forum.vassalengine.org/u/downs)\
**Post date:** [May 9, 2013, 7:29pm UTC](https://forum.vassalengine.org/t/how-to-re-randomise-a-layer-until-a-specific-layer/5969/2 "2013-05-09T19:29:58Z")

</div>

Your problem might be some missing quotes around the player side names:  
try {(PlayerSide==“Adam” && player\_Level==1) || … }

Without quotes, Adam is believed to be a variable and is evaluated as 0.  
(there are no quotes in the “native” syntax, without braces: PlayerSide = Adam && player\_Level = 1)

---

<div class="post-metadata">

**Author:** ![Benkyo](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/benkyo/32/3289_2.png) [@Benkyo](https://forum.vassalengine.org/u/Benkyo)\
**Post date:** [May 9, 2013, 10:37pm UTC](https://forum.vassalengine.org/t/how-to-re-randomise-a-layer-until-a-specific-layer/5969/3 "2013-05-09T22:37:43Z")

</div>

I tried the trigger condition with quotes and it works! Thanks for the tip! Until now I’d been using “” for {} conditions, but only because the names had spaces in them. I hadn’t realised it was always required.

---

<div class="post-metadata">

**Author:** ![Brent\_Easton](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/brent_easton/32/10_2.png) [@Brent\_Easton](https://forum.vassalengine.org/u/Brent_Easton)\
**Post date:** [May 9, 2013, 10:52pm UTC](https://forum.vassalengine.org/t/how-to-re-randomise-a-layer-until-a-specific-layer/5969/4 "2013-05-09T22:52:50Z")

</div>

The syntax of expressions inside the {} is (almost) EXACTLY the same as the Java Programming language, so you can look up a basic Java tutorial for ideas. All Strings must be within double quotes. Variable name must be either unquoted, or if they have a space in them, use GetProperty(“variable name with spaces”).
