Forum Discussion
ThomasUmphres
2 years agoCommunity Member
Making Variables Round to Whole Number Rather Than to 2 Decimals
I have a pretty complex training I'm putting together using a lot of variables where numbers are being displayed with 1 or 2 decimal places. I want to force those numbers to show as rounded whole nu...
WaltHamilton
2 years agoSuper Hero
As of yet, it seems that you should stay away from ChatGPT, as you will probably have to train it. Here is a script that will work
var player = GetPlayer();
var numValue = player.GetVar("NumericEntry");
var JSRoundedNum = numValue.toFixed(2);
player.SetVar("RoundedNum",JSRoundedNum);
NumericEntry is the name of your variable in SL, and RoundedNum is the name of the Text variable that it will return. (JS doesn’t distinguish between text and numeric variables, so SL considers them as text.)
Related Content
- 10 months ago
- 10 months ago
- 10 months ago
- 10 months ago