Sending a result variable to an external leader board database using JavaScript

Jan 30, 2015

Hi all

I am trying to send a score variable to a leader board using a bit of JavaScript in a trigger.

The score variable is named in Storyline as UserTOTAL and my Javascript is

parent.RecordScore(GetPlayer().GetVar("UserTOTAL"));

However when it runs it generates an "Undefined" error.

Could anyone help me to what I am doing wrong?

Thanks

4 Replies
Jackson Hamner

I don't know if this is the reason but maybe splitting the code onto different lines might help. I don't see why this would be the case, but perhaps all of that happening in one line is causing an issue. So something like this might work?

var player = GetPlayer();
var score = player.GetVar("UserTOTAL");
parent.RecordScore(score);

I'm not sure why else you might be getting 'undefined', It usually means that the variable doesn't have a value set to it. So if it definitely has a value, and is the correct name, then I'm not sure why exactly it is not working...

Here is some more information about "Undefined" - https://javascriptweblog.wordpress.com/2010/08/16/understanding-undefined-and-preventing-referenceerrors/

I hope you get it working! I'd love to hear the solution when its fixed.

 

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