Forum Discussion

JosCabrera's avatar
JosCabrera
Community Member
2 months ago

Setting a maximum value for a number variable

Hello,

I am using Articulate Storyline 360, and I am trying to use a condition in a trigger to set a maximum value for a number variable.

My trigger says,

Add value 1 to S1D2_End_Counter

When the timeline starts on this layer

if S1D2_End_Counter < value 5

I expected that the value of S1D2_End_Counter would stop at 4. However, 1 will continue to be added to variable past 5.

I imagine there is another way to do this or perhaps there is an error in how I set up my trigger.

I would appreciate learning your thoughts about this issue.

-José

  • Hi JosCabrera, your logic looks correct, and the variable should only reach a value of 5. Check your variables window, and check the usage of S1D2 and ensure the variable is not being used elsewhere in the project. From the logic you have shown, it should reach 5 and not pass 5.

    I don't suppose you are able to share your Storyline file (stripped down just to demonstrate the issue). Also, just make sure you are up to date on your version.

    • JosCabrera's avatar
      JosCabrera
      Community Member

      SamHillThank you for your reply.

      I created a stripped down version of what I am attempting, and it works, which was unexpected. 

      In the attached file, the logic in the trigger conditional has the effect of imposing a maximum value on the variable.

      In the full version, the trigger for the counter variable is used on 4 slides. Does that matter (compared to being used on two slides like in the attached example)?

      Otherwise, I'll have to ponder what in the full version could be interfering with the trigger conditional.

      • JosCabrera's avatar
        JosCabrera
        Community Member

        While troubleshooting this issue, I discovered that one of the places the variable was used in did not have the correct conditional logic, which led to the value of the variable exceeding the desired value.

        I also observed in Articulate Storyline 360, that the conditional logic needed to be 1 less than what I wanted it to be. In this case, I wanted the maximum value to be 4, and to achieve that I needed to set the condition to < 4 instead of < 5.