Toggle True and False Variable in Articulate Storyline 360

I have been working with Storyline for years and there is one powerful feature that I have overlooked till now. When I was back at eLearning Brothers building a lot of templates I wish I would have known about this feature, and it is a simple way to toggle the True/False variable true and false.

What I would do to work around this was assign the variable either true or false to begin with and then if an item was clicked I would turn it to true if it was false or false if it was true which could work sometimes but it was not reliable and it makes me feel ashamed for not catching this but it goes back to coding, look at this trigger in Storyline.

See in this trigger we are adjusting the variable saying that we are going to change the variable of LightsOn to true when the user clicks. In code this is called an assignment we are assigning the value of True no matter what, assignments are not checking anything they are just doing what they are told. Now I could add a condition to this trigger like this.

But one problem with that is I need to then add a new trigger to do the opposite to turn it back to false if it is true.

More triggers in Storyline means more code, more code means it takes longer to run. This should not keep you from doing code but one rule of thumb is to always write the least amount of code possible to help load time, reduce logic errors and make it more readable for other developers.

So the same rule should apply to Storyline. So there is actually a much more simple way to reduce the amount of triggers in Storyline to toggle the true to false and then back and it comes just by changing one little drop down box.

Instead of assigning the value we are going to take the operator section and select the drop down box and select NOT Assignment

What that will do is toggle the variable back and forth so if it is currently true, it will change it to false and then if it is false when the trigger happens it will change it back to true.

So here is a practical example. If I have an interaction with a light switch that has an on and off state and I want to switch the switch to on if the variable is true and the state to off if the variable is false. I first set up the states then create a variable called LightsOn. By default the variable will be set to false. What we want to do is change that variable to true if it is clicked so let’s add this trigger to the light switch when it is clicked.

Nothing on the stage changes because we then need to add a trigger when the variable changes to change the state of the light switch if it is true or false. So this one will change it to true.

And because I added the trigger on the variable changing, it will change no matter what triggers the variable to change. Not lets change it back to off if the variable is false.

The off was more normal state so I am just changing it back to that if it is false. That is it! Now when you click the light switch you will see if flip on and off. I could now insert a light bulb with an on and off state and add the same state change triggers to have it turn off an on.

I see this being a very powerful feature to allow the user to make adjustments and interact with the content rather than just be sitting and listening to animation get them involved and have them interact with the content.

Watch the video here.

Leave a Reply

Your email address will not be published. Required fields are marked *