Jump to content

Recommended Posts

Posted

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+006


Am I doing something wrong here? This is with stock 3.6.2.

Posted

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 ... :/

Posted

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!

Posted

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 =)

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...