adambeer Posted February 24, 2015 Share Posted February 24, 2015 Im not sure if Ive ran into a bug here with the setText() method for guiTextCtrl but I am using one as a currency display and when I am adding larger numbers the text gets messed up. function increaseCurrency(%amount) { %dollars = someScriptObject.currency; %current = %dollars + %amount; currencyTextGui.setText("$" @ %current); } So I call something like this:currencyTextGui.setText("$" @ 1532500*2);and the result that gets printed looks like this:$3.065e+006Am I doing something wrong here? This is with stock 3.6.2. Quote Link to comment Share on other sites More sharing options...
Steve_Yorkshire Posted February 24, 2015 Share Posted February 24, 2015 Torque truncates things with more than 6 decimal places (just rotate stuff in the editors and call their transform) I think to keep everything easy for sending over a server to remote clients. I'm pretty sure that there is a way to get around this for TS ... but I can't remember what it is ... which isn't terribly helpful ... :/ Quote Link to comment Share on other sites More sharing options...
adambeer Posted February 25, 2015 Author Share Posted February 25, 2015 Any idea where I could remove the truncation? This particular game in working on is single player so im not too concerned with whatever issue the truncation was trying to resolve. If you do happen to remember how to get around this let me know! Thanks! Quote Link to comment Share on other sites More sharing options...
JeffH Posted February 26, 2015 Share Posted February 26, 2015 somewhere in the interpreter it truncates using %.6g or %g in the dSprintf call I believe. You can up the precision most likely, or expose 64-bit math functions to TS =) Quote Link to comment Share on other sites More sharing options...
buckmaster Posted February 26, 2015 Share Posted February 26, 2015 How about we always render numbers as decimals, and add a number formatting function? That way people can actually choose how to display values? Quote Link to comment Share on other sites More sharing options...
adambeer Posted February 27, 2015 Author Share Posted February 27, 2015 Sounds good to me! Any advice on where I could get started with this? Quote Link to comment Share on other sites More sharing options...
buckmaster Posted February 27, 2015 Share Posted February 27, 2015 Actually, this is simpler than my suggestion above; ignore the first half. Just define a new console function that returns a string formatted hw you like. Here's an example of returning a string. As for formatting, I'd recommend getting the integer part, and the fractional part (to 2 DP) separately and concatenating them using dSprintf. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.