# Is there a way to randomly select a scene?

Jul 18, 2022

I have a course where I've created a content scene, and then I have a number of scenes that are setup as scenarios to test the learner's knowledge.  The course is recurring training, so I'd like to randomize the scenario scenes so that learners aren't seeing the same one every time they take the course.

So, is there any way to setup a trigger to jump to a random scene?

Thanks in advance for the help.

v/r

Jay

###### 12 Replies

Hey Jay,

I think the random variable option could be a good fit. I have attached a quick mockup of something that could possibly work.

There's no trigger for jumping to a random scene.

Here's an option that might work:

• Put the first part of each scenario on a question slide in a Question Bank (QB).
• Insert a draw from the QB that randomly picks one slide.

Here are some User Guide entries that might help:

Conditions in combination with a random variable can do the trick. If var =1 gotoScene 1, if var =2...et. etc.

Ron,

Thanks much for the example.  It kick started my thinking about how to do what I want to do.  I'm going to use your example, but now I need to dust off my JS knowledge and create a script that will generate three random numbers.

thanks again!

Jay

Thank you sir!

Like I said before...I need to brush up on my JS as it's been awhile.  The rest of what I need to do is assign the three random numbers to three variables within Storyline.

In the script you sent, what is ([...nums]);?  Is that identifying the values within the set as numbers?

Yes an array with the 3 random numbers in it. I set it to 1 variable now...you can easily assign the 3 values to 3 separate variables.
Added it to the sample now.
Basically this is how you get a specific value from a Set.
`player.SetVar("val1",[...nums.values()][0]);`

Updated in the sample and here is the Storyline.

Sets have the specific quality that they never can have duplicate values in it. Only unique values allowed.

Hey Jay -

Glad you have a solution.  In the sample I created, I made sure there were no duplicates without script.  But if you know Javascript, that might be a little more straightforward.

Ron...if you have an example without using JS I wouldn't mind seeing it.  Even if I don't use it in this particular application, it's always useful to see new ideas/possibilities.

Thanks!

Jay

The one I posted earlier in the thread- reposting here