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

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)

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!)

1 Like

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?

An alternative to @jrwatts method would be to define 6 Trigger Action traits

  • Trigger Action
    • Key: SomeKey
    • Actions: [ActionA]
    • Expression: {LocationName == "ZoneA"}
  • Trigger Action
    • Key: SomeKey
    • Actions: [ActionB]
    • Expression: {LocationName == "ZoneB"}
  • Trigger Action
    • 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

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

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:

(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.