Jump to content

Possible bug with guiTextCtrl


Recommended Posts

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:


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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

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

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