Forum Discussion

OrganizationSta's avatar
OrganizationSta
Community Member
2 years ago

Random Number Generator with Exceptions

I'm using Storyline 360 to create a video game. Every round the player shuffles a deck of cards and draws one which they then respond to. There are ways to create a random number and i'm ok with that. 

The twist is that some cards only come up if certain conditions are met, i.e. certain counters (variables) are above or below a certain threshold. I have 3 such counters, they're independent from one another (meaning just because one is up doesn't mean another one is). Let's say for sake of argument, counter1, counter2, and counter3. 

With 2 counters i can say: "Set variable X to a random number between 10 and 20" and "Set variable X to a random number between 0 and 20 if counter 1 is above the threshold" and "Set variable X to a random number between 10 and 30 if counter 2 is above the threshold" and "Set variable X to a random number between 0 and 30 if counter 1 is above the threshold and counter 2 is above the threshold". (The numbers are arbitrary just for the sake of being able to ask the question.)

Does anyone have any ideas for 3 counters? Is there a way to say "Set variable X to a random number between 1 and 10, and between 20 and 30"? That way, i can assign a range of numbers to each counter and therefore include that particular range if that counter is tripped. 

  • Wow, thank you! 

    So, if I understand correctly, you set it up so that for the one case where Variable1 and Variable3 are above the threshold but Variable2 is below, if a number between 11 and 20 is drawn, which it's not supposed to, you re-trigger the random number generator until it draws a number that's not between 11 and 20. Yes? 

    That's super clever! :) Thank you for setting this up for me; i had not thought about this possibility. :) 

  • Yes, that is how it works, and you're welcome. PIAWYC  (Pass it along when you can).