Explore the community Forums Lectora Lectora Questions & Answers Random variable values

Viewing 1 post (of 1 total)
  • Author
  • #264904 Score: 0
    Profile photo of gwempz

    2 questions about random variable values:1st: I see you can set a variable to initially be random, and this retains the randomly generated value throughout a session. But is there a way to reset this single variable when each page loads? The only way I see to do this is with a “Reset All Variables” action. This won’t work because I have other variables I need to retain their values.2nd: Part of what I’m trying to achieve is assigning a random value from 1 to 4 onto 4 buttons. To do this I need 4 variables for each button that don’t repeat (can’t have 2 buttons with a value of 3, etc). I came up with code to achieve this and created actions in this order all set to occur On Show:

    modify variable: _varButton1 = _random#modify variable: _varButton2 = _random#modify variable: _varButton3 = _random#modify variable: _varButton4 = _random#modify variable: _varButton2 += 1modify variable: _varButton3 += 2modify variable: _varButton4 += 3modify variable: _varButton2 -4 if _varButton2 > 4 modify variable: _varButton3 -4 if _varButton3 > 4 modify variable: _varButton4 -4 if _varButton4 > 4

    In theory this should work perfectly, but Lectora is ignoring the if statements and my values are higher than they should be (1-8). Is this a bug, or am I doing something wrong??? Any insight would be appreciated!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.