Forum Discussion
Random Number
Let me start out by saying I know just enough JavaScript to get by... I have developed a quiz where the user competes in a game with the computer. If the user gets the answer wrong the computer gets to "guess." I used a random number generated from SL. My trouble is that I don't want the computer to guess the same answer as the user. I have tried several combinations in JavaScript but just can't get it to work. Your help is greatly appreciated! This is my code:
var player=GetPlayer();
var i=player.GetVar("PlayerResponse");
var y=player.GetVar("RandumNumber");
while (y = i) {
var randomnumber = Math.floor((Math.random()*4)+1);
var i = randomnumber;
}
player.SetVar("RandumNumber",randomnumber);
player.SetVar("worked",y);
- OwenHoltSuper Hero
Select the random number from an array, but before the computer guesses the answer, remove the users selected number from the array.
https://community.articulate.com/discussions/articulate-storyline/ensuring-a-random-number-is-not-re-picked#reply-492986 - susanjohnson1Community Member
Thanks!