JavaScript Help

Does anyone see anything wrong with my JavaScript below? I've got this being executed on a slide just after a trigger that submits to the results slide, but nothing is happening.

var player = GetPlayer();
var totalScore = player.GetVar("Results.ScorePoints");
var finalScore = Math.floor(totalScore/100);
player.SetVar("FinalScore", finalScore);
alert("Results.ScorePoints = " + totalScore);
alert("finalScore = " + finalScore);

The "alert()" lines are in there just to test, but they are not executing. Also, I have a %FinalScore% reference in a text field on that page, and it's showing 0 even though I know I'm entering the correct answers on the quiz questions.

This is my first Storyline project after 20 years of using other tools. Please help me figure out what I'm doing wrong. What additional info do I need to provide?

Thanks.

4 Replies
David Carter

Upon further testing, I found that the quiz is being scored, and the correct number is in "Results.ScorePoints," but for some reason, the JavaScript doesn't seem to be triggering. Here's my triggers panel for that page...

Here's what the trigger looks like when I edit it...

Here's the JavaScript as it appears in Storyline...

David Carter

Final version of JS is...

var player = GetPlayer();
var totalScore = player.GetVar("RawScore");
var finalScore = Math.floor(totalScore/100);
player.SetVar("FinalScore", finalScore);
alert("Results.ScorePoints = " + totalScore);
alert("finalScore = " + finalScore);

"RawScore is set to the value of "Results.ScorePoints" using an "adjust variable" trigger.