var player = GetPlayer(); var num = player.GetVar("ldt"); if ((num*0.6667) < 2625) { var val = Math.round(num*0.6667); } else { var val = Math.round(2625+(((num*0.667)-2625)*.5)) ; }
var player = GetPlayer(); var a = player.GetVar("Anualsallary"); var P = player.GetVar("KF5"); var r = .05; var n = 12; var z = r / n; var u = 1 + z; var t = 25; var y = n * t; var m = a / 12 * .08; var val = ( P * Math.pow(u, y)) + (m * Math.pow(u, y) - 1) / z); player.SetVar("KF10",val);
5 Replies
Here's the code that should work. I have also attached an example story file for you to take a look at.
var player = GetPlayer();
var num = player.GetVar("Life7074");
var val = Math.ceil(num/1000)*1000;
player.SetVar("Life7074",val);
Thank you. It worked perfectly
Maybe you can help wit this:
var player = GetPlayer();
var num = player.GetVar("ldt");
if ((num*0.6667) < 2625) {
var val = Math.round(num*0.6667);
} else {
var val = Math.round(2625+(((num*0.667)-2625)*.5)) ;
}
player.SetVar("LDT",val);
I’m not at work today. But from taking a quick look, I see that ldt is all lowercase in line 2 and LDT is capitalized in the last line.
Javascript is case sensitive. Make sure the variable name matches how you have it declared in your storyline variables.
var player = GetPlayer();
var a = player.GetVar("Anualsallary");
var P = player.GetVar("KF5");
var r = .05;
var n = 12;
var z = r / n;
var u = 1 + z;
var t = 25;
var y = n * t;
var m = a / 12 * .08;
var val = ( P * Math.pow(u, y)) + (m * Math.pow(u, y) - 1) / z);
player.SetVar("KF10",val);