Triggers conditions not working : The trigger override each other.

Mar 23, 2021

Hi, I've been working with storyline for a while now and it seems to the way conditions worked has changed.

For instance :

I have an object with 3 states (A,B,C) linked to a number variable (Range) with a default value of 100.

My triggers are :

1) Substract 50 to Range when user clicks on Object.

     - If Range is > 0  

 

2) Set Range to 100 when user clicks on Object

    - If Range is = 0

 

There is no way these two conditions can be true at the same time. Nevertheless, here is what happens :

- First click sets Range to 50 (as expected)

- Second click sets Range to 100 (instead of 0 then third click setting it to 100) as if it was set to 0 then clicked again and set to 100 directly.


This is driving me crazy because I loose hours finding workarounds for basic functions like this and I don't understand what I am doing wrong. It's like articulate considers I'm constantly clicking from the first click on.

Just to be clear, what I want is :

Range = 100
- clic 1 : Range = 50

- clic 2 : Range = 0

- clic 3 : Range = 100

- ...

 

Please, does anybody have an idea of what I am doing wrong ?

Thanks

6 Replies
Walt Hamilton

You wrote:

There is no way these two conditions can be true at the same time. Nevertheless, here is what happens :

But if the first trigger finds Range to be 50 ( > 0), it is true, and it changes Range to 0. Then second trigger finds Range to be 0 (=0), so it is true, and it sets Range to 100. Triggers are executed very rapidly, but in order,  not simultaneously, which is why trigger order is important.

All triggers that fire when object is clicked are executed every time object is clicked.  So when Range is 100, first TRIGGER, not clic, subtracts 50 and Range is 50. Second trigger isn't activated because Range isn't 0. Next time it is clicked, first trigger subtracts 50, and range is 0. Second trigger sets Range to 100, because it is 0.

Try this:

Subtract 50 from Range.

Set Range to 100 if Range < 0.  Be sure to keep them in this order.

 

Rémy Elouard

Hi, thanks for your answer!

I get that triggers are executed in a certain order. What bothers me is that here, a trigger should not be executed and is executed anyway.

"But if the first trigger finds Range to be 50 ( > 0), it is true, and it changes Range to 0. Then second trigger finds Range to be 0 (=0), so it is true, and it sets Range to 100. "

The problem is, the second trigger (Set var to 1000) shouldn't be executed because is conditions are :

Set Var to 100 :

  - When clicks
 - If Var = 0

However, when the user clicked, Range was equal to 50, not to 0.
And when Range was equal to 0, there was no click. So how exactly does Storyline consider the second trigger should be executed ? Its triggering condition (click) and its specification (Range = 0) where never true together at the same time. I might be wrong butI really thought that trigger should read like :

When the user clicks, if (and only) if Range is equal to 0, set Range to 100

The conditions Range > 0 and Range = 0 cannot be true at the same time so the same click should not activate both triggers.

Take a light switch. If the light is on and you click it, the light turns off. If it is off and you click it, the light turns on.

But with  the logic here, we would have.

Light off => click => light On => Light Off.

And everybody would live in the dark forever.



Anyway, I found somthing that works, even if it still bothers me :

1) When users click, substract 50 to Range if Range >= 0
2) When users click, set Range to 100 if Range <0

It only works because the second trigger is activated even though it shouldn't.



Anyway thanks for your solution, I will try that too and keep it in mind for next time !

Walt Hamilton

You as a person can see both triggers at the same time, evaluate them both as to their condition when clicked, and perform only one of them.

A computer on the other hand, doesn't think that way. Even though they are so fast that they seem to be doing thing instantaneously, they can execute only one command at a time. There is an executive that decides what to do, and sends orders out to agents to have them done. So when you click, it loads up all the triggers that are set to be executed when that item is clicked. With that list in hand, it starts through the list, reads it one item at a time, and sends out an  agent to do it. The order to subtract from Range is performed by an agent before the executive can fully process the second trigger. Therefore, the trigger does not say "Perform Action xxx if condition is yyy when object is clicked". Rather it says "When object is clicked, begin performing action xxx if condition is yyy AT THIS TIME."

Think of your light switch analogy. If  you and I got together to change the light switch, I (as executive) would tell you (as agent) "Go in there, and turn that light on if it is on." You might ask, "What if it's already on?" I'd say,"If it's on, turn it off."  Because you're human, you can hold those two ideas in your head at the same time, and you will go in there and toggle the switch. But if we were parts of a computer, you could not hold two ideas. I'd have to give those two commands one at a time. So, just like you proposed, I'd say, "Go in there, and if that light is off, turn it on." You would do it and come back and say, "Now what, Boss?" I'd say, "Go in there and if that light is on, turn it off." You would, and we would be in darkness.

That exact process has happened to many SL developers, who wanted to toggle a variable or state. Finally, Articulate developed the toggle trigger, which works to change a T/F variable to its other value, and a Selected state when is chosen on first click, and de-chosen on the next.

You can't use the T/F variable, nor the Selected state because you have three conditions. That's why I recommend these two triggers.

1. Subtract 50 from Range - always, no matter what (no need to check if it is >= 0, the next trigger insures that it always will be.)

2. Set Range to 100 if Range =< 0

 

Rémy Elouard

I get what you're saying and it makes sense, however even if storyline isn't able to "hold two thoughts" as you put it, it seems doable to first, when clicked, make a first pass on all the triggers that are supposed to be executed at click and select the one whose conditions are true at the moment of the clic, then execute them one by one.

It would make a lot more sense than executing a trigger whose condition isn't fulfilled at the moment of the triggering clic.

All that said, I understand what you mean.

However something still bothers me. When I first met that problem, I tried delegating with the following triggers :

1) at clic on OBJ1, set Obj2 to state A if Var = x

2)at clic on OBJ1, set Obj2 to state B if Var = y

3)when Obj is State A, set Var to x

4)when Obj is State B, set Var to y

assuming that SL would first execute the clic triggers then try out the state ones.

Instead here is the result :

Var is x => clic => Obj1 to state A => Var to y => Obj1 to state B => Var to x.

And I still can't wrap my head around that.


Also, not that it is relevant with the current topic but I'm getting a bit tired of SL just quitting on me when I'm simply trying to change a condition in a trigger. It happens at least 2 or 3 times a day and I have to save every 5 minutes not to loose work.


Thanks again for your explanations !

Walt Hamilton

Also, not that it is relevant with the current topic but I'm getting a bit tired of SL just quitting on me when I'm simply trying to change a condition in a trigger. It happens at least 2 or 3 times a day and I have to save every 5 minutes not to loose work.

I have learned to completely close and restart SL once an hour, no matter what. Very time consuming, but it seems to help some, and I need to stand up and walk once an hour, anyway. Good for my health, good for SL's health.  :(

Rémy Elouard

That's doable with little projects. With big ones, it takes so much time to close/save them that I do it as scarcely as possible. My work PC is not that bad but I swear sometimes I just clic on the project file and wait half an hour before I can work on it. You can imagine how desperate I get when SL crashes 5 times a day.