Continuously checking variable values to trigger action
Sep 14, 2021
Hi, while working I always see that each trigger is dependent on something happening. But this is the scenario I have:
One slide. 15 objects to select and deselect. I want to add 1 to a number variable (let's say counter) each time an object is selected/interacted with. When the value reaches a certain number (let's say 5) I trigger another action. Now how do I
- add a number to a variable each time an object is selected
- constantly monitor the value of that counter variable to trigger an action?
I can of course add a trigger to all 15 objects so whenever any of the object is selected, it check whether the counter variable is 5 or not and then take the desired action. That means 15 triggers.
Any ideas? Thanks
6 Replies
You can add a value or variable with the adjust variable action.
The when variable changes trigger listens for changes in a variable
Hi Phil, thanks for your reply. That makes sense. I can trigger the action when my counter variable changes and then I will add the condition IF counter = 5.
However, I am still trying to figure out how I can add/increment a variable each time an interaction occurs?
Hi Minhaz,
Adding a trigger to each of the 15 objects you want learners to click is likely the most straightforward way to add a number to your variable each time one of those objects is selected.
The first image I've attached shows one way to set up your Adjust Variable trigger settings to do this.
Once you've set up that first trigger, the rest are much faster to add. The second screenshot shows how this can work. Just copy and paste that first trigger, in your new trigger copy click the Object, and then choose the new object you want a trigger for. With this copy/paste method, it should only take a few seconds to create each additional trigger.
Thanks a lot for your solution. It helped.
While we are on the subject of adding values to variables, is there any way to directly add two variables? For example, if there are two variables x and y, currently we have to add the variable x to y and therefore changing the value of y as well.
But if we take another variable, lets say sum. Can we directly make this calculation of sum = x + y?
Currently we have to, Add variable x to sum, then add variable y to sum to get to sum = x + y.
Create a variable called sum and add x and y to it
Sent from my iPhone
Hi, yes. That is the way but in that way I cannot check whether the sum = x + y. I needed to check that condition to trigger another action.