# There's a way to Trigger an Action only when all the "previous" Trigger Action Conditions fails?

**URL:** <https://forum.vassalengine.org/t/theres-a-way-to-trigger-an-action-only-when-all-the-previous-trigger-action-conditions-fails/86736>\
**Category:** Module Design\
**Created:** [September 28, 2025, 7:53pm UTC](https://forum.vassalengine.org/t/theres-a-way-to-trigger-an-action-only-when-all-the-previous-trigger-action-conditions-fails/86736 "2025-09-28T19:53:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parduz](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/parduz/32/2604_2.png) [@Parduz](https://forum.vassalengine.org/u/Parduz)\
**Post date:** [September 28, 2025, 7:53pm UTC](https://forum.vassalengine.org/t/theres-a-way-to-trigger-an-action-only-when-all-the-previous-trigger-action-conditions-fails/86736/1 "2025-09-28T19:53:19Z")

</div>

In a piece, the general idea is to have a lot of check on when it ends its move, and then having a last actions that sends it back if all the previous checks failed.

So, if i were programming, i will write a code like

`if (LocationName==”ZoneA”) do ActionA`  
`else if (LocationName==”ZoneB”) do ActionB`  
`else if (LocationName==”ZoneC”) do ActionC`  
`else if (LocationName==”ZoneD”) do ActionD`  
`else if (LocationName==”ZoneE”) do ActionE`  
`else return to OldLocation`

Now, i’m able to do the all the Trigger Action traits, but how can i implement the final “else” statement?

_(without writing all the previous test but negated, as i may need to add more and i’d like to avoid to have to always update also the last one)_

---

<div class="post-metadata">

**Author:** ![jrwatts](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/jrwatts/32/6972_2.png) [@jrwatts](https://forum.vassalengine.org/u/jrwatts)\
**Post date:** [September 28, 2025, 8:51pm UTC](https://forum.vassalengine.org/t/theres-a-way-to-trigger-an-action-only-when-all-the-previous-trigger-action-conditions-fails/86736/2 "2025-09-28T20:51:36Z")

</div>

Use the Java ternary expression, `?:`, instead of if statements. Your example would be: `{LocationName == “ZoneA” ? ActionA : LocationName == “ZoneB” ? ActionB : LocationName == “ZoneC” ? ActionC : LocationName == “ZoneD” ? ActionD : LocationName == “ZoneE” ? ActionE : ReturnToOldLocation}`(leave out the opening and closing braces if you’re using this in a `Calculated Property`).

Edit: OK, I re-read your initial question, and you want a Trigger Action that only triggers if none of the others do. To do that, you would need use a “flag” Dynamic Property with a wrapping Trigger Action around the others. Basically, the new Trigger Action would set the flag DP to false, then call each of the “Zone” trigger actions. The “Zone” trigger actions would set the flag DP to true (in addition to doing the appropriate action). Finally, the wrapping trigger action would call the “else” Trigger Action, which would be set to only fire if the flag DP is still false. (Important edit to the end of that last sentence; I had the logic backwards!)

---

<div class="post-metadata">

**Author:** ![Parduz](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/parduz/32/2604_2.png) [@Parduz](https://forum.vassalengine.org/u/Parduz)\
**Post date:** [September 28, 2025, 8:54pm UTC](https://forum.vassalengine.org/t/theres-a-way-to-trigger-an-action-only-when-all-the-previous-trigger-action-conditions-fails/86736/3 "2025-09-28T20:54:07Z")

</div>

I’m sorry, but i don’t get it.  
How “ActionA” etc translates as Named Commands to be used inside the piece?

-edit-

Oh, you meant i should use a calculate property like that and then use a Trigger Action for each of its possible values?

---

<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:** [September 29, 2025, 5:39am UTC](https://forum.vassalengine.org/t/theres-a-way-to-trigger-an-action-only-when-all-the-previous-trigger-action-conditions-fails/86736/4 "2025-09-29T05:39:41Z")

</div>

> [@jrwatts](#):
>
> Use the Java ternary expression,

An alternative to @jrwatts method would be to define 6 [Trigger Action](https://vassalengine.org/doc/latest/ReferenceManual/TriggerAction.html#top) traits

- [Trigger Action](https://vassalengine.org/doc/latest/ReferenceManual/TriggerAction.html#top)
  - Key: `SomeKey`
  - Actions: [`ActionA`]
  - Expression: `{LocationName == "ZoneA"}`

- [Trigger Action](https://vassalengine.org/doc/latest/ReferenceManual/TriggerAction.html#top)
  - Key: `SomeKey`
  - Actions: [`ActionB`]
  - Expression: `{LocationName == "ZoneB"}`

- …
- [Trigger Action](https://vassalengine.org/doc/latest/ReferenceManual/TriggerAction.html#top)
  - Key: `SomeKey`
  - Actions: [`ReturnToOld`]
  - Expression: `{LocationName != "ZoneA" && LocationName != "ZoneB' != LocationName != "ZoneC" && LocationName != "ZoneC" && LocationName != "ZoneD" && LocationName != "Zone"}`

Note that all the traits react to the same key `SomeKey`, but have mutually exclusive conditions in `Expression`.

Yours,  
_Christian_

---

<div class="post-metadata">

**Author:** ![Parduz](https://forum.vassalengine.org/user_avatar/forum.vassalengine.org/parduz/32/2604_2.png) [@Parduz](https://forum.vassalengine.org/u/Parduz)\
**Post date:** [September 29, 2025, 6:11am UTC](https://forum.vassalengine.org/t/theres-a-way-to-trigger-an-action-only-when-all-the-previous-trigger-action-conditions-fails/86736/5 "2025-09-29T06:11:26Z")

</div>

> [@cholmcc](#):
>
> [Trigger Action](https://vassalengine.org/doc/latest/ReferenceManual/TriggerAction.html#top)
> 
> - Key: `SomeKey`
> - Actions: [`ReturnToOld`]
> - Expression: `{LocationName != "ZoneA" && LocationName != "ZoneB' != LocationName != "ZoneC" && LocationName != "ZoneC" && LocationName != "ZoneD" && LocationName != "Zone"}`

Yeah, but this is exactly what i’d liked to avoid (i tried to explain with my poor english:)

> [@Parduz](#):
>
> (without writing all the previous test but negated, as i may need to add more and i’d like to avoid to have to always update also the last one)

In the end, I find the first idea the better, also thanks to the fact that the Calculated Property field retains empty lines and multiple spaces, so i can have it like this:

```auto
(LocationName.contains(“Battlefield”)) ? “Play” :
(LocationName==“Order Tokens Area” ) ? (Owner!=0 ? “Discard” : “DoNothing” ) :
(LocationName==“P1 Dashboard” ) ? (Owner==0 ? “AssignToP1” : (Owner==1 ? “DoNothing”:“GoBack”) ):
(LocationName==“P2 Dashboard” ) ? (Owner==0 ? “AssignToP2” : (Owner==2 ? “DoNothing”:“GoBack”) ):
(LocationName.contains(“P1Orders_”) ) ? (Owner==0 ? “AssignToP1” : (Owner==1 ? “DoNothing”:“GoBack”) ):
(LocationName.contains(“P2Orders_”) ) ? (Owner==0 ? “AssignToP2” : (Owner==2 ? “DoNothing”:“GoBack”) ):

“GoBack”

```

and it is very easy to mantain and to add new conditions.
