Forum Discussion

GlendaDeHoff-0c's avatar
GlendaDeHoff-0c
Community Member
3 years ago

Help please - JavaScript not returning values

I am stuck.  I know enough about JavaScript to be dangerous and below is the code that I am using.  My Storyline file is attached. I would greatly appreciate someone in the know taking a look and telling me what I did wrong.

Thank you in advance!

var player = GetPlayer();

var LENGTH = player.GetVar(“ConnectorLength”);//user entry - connector length

var HEIGHT = player.GetVar(“Height”);//user entry - their height

var RINGDIST = player.GetVar(“dRingDistance”);
//user entry - distance from D-ring to anchor

var ANCHOR= player.GetVar(“AnchorPoint”);
//user selects location of anchor point

var DECELDIST = player.GetVar(“DecelerationDistance”);
//user entry - deceleration distance (connector stretch when activated)

var SAFETY = player.GetVar(“SafetyFactor”);
//constant value set in Storyline

var RINGSHIFT = 1; //harness slip - constant value used for calculation

var TOTALFALLDIST = player.GetVar(“FallDistance”);//calculated and returned to Storyline

var FREEFALL = player.GetVar(“FreeFall”);

var CONNTYPE = player.GetVar(“ConnectorType”);//connector type

var RINGHEIGHT = HEIGHT-1;//employee height-1 ft

/************************ Start ANCHOR Case Statement ************************/
switch (ANCHOR) {
case 1: 
   FREEFALL = LENGTH + RINGDIST;//if d-ring is above anchor
    break;
  case 2: 
     FREEFALL = LENGTH;//if d-ring is level with anchor
    break;
  case 3: 
    FREEFALL = LENGTH - RINGDIST;//if d-ring is below anchor
    break;
}
/************************ End ANCHOR Case Statement ************************/

/************************ Start CONNTYPE Case Statement ************************/
switch (CONNTYPE) {
case 1: 
       break;//do nothing if CONNTYPE = 1 (shock absorbing lanyard)
  case 2: 
     FREEFALL = 0;//if CONNTYPE = 2 (self-retracting lifeline)
    break;
}
/************************ End CONNTYPE Case Statement ************************/

TOTALFALLDIST = FREEFALL +DECELDIST + RINGSHIFT + RINGHEIGHT + SAFETY;
//calculate toal fall distance

alert("FallDistance = " +TOTALFALLDIST);

Player.SetVar(FallDistance,TOTALFALLDIST);//Return FallDistance to Storyline

Player.SetVar(FreeFallDistance,FREEFALL);//Return FreeFallDistance to Storyline