Step 1: Setting up the Master Slide
Before you begin to draft your module you want to adjust your “master slides”.
Click View
Click Slide Master
Adjust them as you see fit to match your specific module’s theme and need, but make sure you have at
least two blank slides. Name one of them NoJavaScript and the other JavaScript.
Why? You may not want or need the script on each of your slides and by controlling which slides use
the “master slide” that has the script it allows for easier troubleshooting down the road. Plus, I have
found that having this trigger as a Slide Trigger does not seem to render the same results.
Now, select the slide you named “JavaScript” and create a trigger “Execute JavaScript”.
Click the button for “Script” and copy/paste in the JavaScript below and then click Ok.
//info after these two slashes are comments to help explain the code should you want to modify (clean version of
the code is in the .Story file as well as in the Resource button in the module.)
var rN = Math.floor((Math.random()*10)+1); // picks # 1-10 can be any # you want
var player = GetPlayer(); // creates variable to talk to Storyline
var itemR=[0,0,0,0,0,0,0,0,0,0]; //empty array to be filled with layer variables. Note: This is set to 10. You must
change (add/subtract) depending on the range you set in var rN above
var valueR=[1,2,3,4,5,6,7,8,9,10]; // you will setup variables in your module (see below) I used L1, L2, etc. I have L1
(layer) being shown if rN=1 when that happens then L1=1, L2=2, and so forth. You can use any # you want, but
keeping it in numeric order helps keep the flow logical.
var randnum=0; //the # to be passed back to the slide to show the layer based upon which # is selected
var fN=0; // value for the For command
var rvw=0; //value to stop a loop if all layers have been picked
1
itemR[0]=player.GetVar("L1"); //assigning array slot 0 with value of L1 variable. Arrays start with 0 not 1. So a
range of 1-10 will be 0-9 in the array. So, in this case I’m checking to see if in a prior call if L1 have a value and if so
what it is. That will then be matched below against the rN and valueR[] and either gets the module to show that
layer or resets rN if the layer had already been seen.
itemR[1]=player.GetVar("L2"); // ditto, but L2, etc
itemR[2]=player.GetVar("L3");
itemR[3]=player.GetVar("L4");
itemR[4]=player.GetVar("L5");
itemR[5]=player.GetVar("L6");
itemR[6]=player.GetVar("L7");
itemR[7]=player.GetVar("L8");
itemR[8]=player.GetVar("L9");
itemR[9]=player.GetVar("L10");
//following is the For command to compare whether the value in array itemR[x] matches the value in array
valueR[x] and if they match the random #.
for (var x=0;fN == 0;x++)
{
if (rvw>1)
{fN=11; //if you change the rN range then this fN= that number plus 1. So if 1-3 range then fN=4, etc.
}
if (rN>10) //If you change the rN to be 1-3, 1-30, 1-100 then rN> that final number – such as 3, 30, 100
{rN=1;
x=0;
rvw++;
}
if ((itemR[x] == valueR[x]) && (itemR[x] == rN)) //if all equal then the # and layer have been seen
{rN++;
}
if ((itemR[x] != valueR[x]) && (valueR[x] == rN)) // if value and rN match but itemR doesn’t (means 0) then show
the layer for that number.
{fN=rN;
}
}
//once the layer # that is available is determined that # is passed back to Storyline into the variable "randnum"
player.SetVar("randnum",fN);
2
Step 2: Setting up the variables in your module
Based upon the JavaScript code you must create the following variables and initially assign them as a
number with the value of 0.
L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, randnum
Next, if you have more than one slide in which you wish to use this code then set all variables to Zero
when you click Next.
Click New Trigger
o Action: Adjust Variable
o Variable: Select L1, etc.
o Operator: = Assignment
o Value: Value
o Give value of 0
o When: User Clicks
o Object: Next button
Note: Do this for all L1-L10, and Randnum
Instruct variable is just for the 3rd slide to turn off showing you, “Click on each photo…” after you’ve
seen it once. It is not necessary for the random number JavaScript.
3
Step 3: Showing a layer when randnum equals a certain number of your choosing.
I won’t go into details on setting up Layers, but the Trigger is simple:
Click New Trigger
o Action: Show Layer
o Layer: Which one
o When: Timeline Starts
o Object: the Slide you are on
o Click Show Conditions and click the Plus-sign.
If randnum
Operator: == Equal to
Type: Value
Value: # you choose
Click Ok
Click Ok
Repeat for each Layer and # you wish to show your end-users randomly on this
slide.
This may be a lot of information to take in, but once you play around with it I think it will make sense.
The idea is to present information to your end-user, but not in a completely controlled timeline so as to
give it a little variety. In a sense it is taking the concept of the Question Bank’s ability to select only a set
number of quiz questions and present then in any order, and allowing you to do the same with content.
Enjoy!
Rodney Haun
Tilak Learning Group, LLC
Click:
Module: Random No-Repeat Number
.Story file: Random-No-Repeat-Number.story
JavaScript: Random-No-Repeat-Number-JavaScript.docx
Details: Random-No-Repeat-Number-Documentation.docx
4
© Copyright 2026 Paperzz