several functions if in a trigger

Jun 30, 2014

I need to indicate different conditions in a js trigger with several function if. But it does not work (I put the program below). Has Anybodody an idea ?

var player=GetPlayer();
var ranr = player.GetVar("V1");
var ran2 = player.GetVar("V2");
if (ranr>10){
if (ran2>1){
return player.SetVar("TextEntry","coucou");
}
else{ return player.SetVar("TextEntry","ça marche");
}
}

2 Replies
Steve Flowers

Hey Frederic -

Couple of things that might be happening here:

1) You're evaluating based on a number value. player.GetVar returns a string. To reliably convert to an integer use parseInt().

2) Remove return from player.SetVar. Not necessary and likely explains why the method isn't executing.

Try this:

var player=GetPlayer();
var ranr = player.GetVar("V1");
var ran2 = player.GetVar("V2");
if (parseInt(ranr)>10){
if (parseInt(ran2)>1){

player.SetVar("TextEntry","coucou");
}
else{

player.SetVar("TextEntry","ça marche");
}
}

This discussion is closed. You can start a new discussion or contact Articulate Support.