Demos, Design Tips and Tricks

Random Number Generator

A little blast from the past. Before the random fortune teller and the random word generator, I started out pairing together Storyline and Javascript with this simple random number generator. It creates a whole integer between 1 and 10.

randnum

Click here to view

How to do this:

  1. Create a variable in storyline called “randnum”
  2. Add a trigger to execute Javascript when the generate button is clicked. Enter in this Javascript:

var randomnumber = Math.floor((Math.random()*10)+1);
var player = GetPlayer();
player.SetVar(“randnum”,randomnumber);

3. Add in a reference to the storyline variable (%randnum%) where the random number will be displayed.

Easy peasy!