This is for a money/buying system in my game
I need help with this....
Problem:
So I'm having a issue I want to turn a number variable like 10000 to display on set text. 10,000 or every 999 the next number over will add a comma.
Found a Solution (Sort Of):
I tried tons of different ways then came across this old forum post.
construct.net/en/forum/construct-2/how-do-i-18/string-numbers-commas-127611
Anyway they used Events and Actions like this to create something that sort of works.
Problem is it adds commas before needed. 999 ends up being ,999
System: Every tick
System: For "" from 0 to tokencount(str(PocketCASH), "")%3
-> PocketCASH: Set text to left(str(PocketCASH), LoopIndex)
----+ System: tokencount(str(PocketCASH), "") > 1 and len(str(PocketCASH)) > 3
----+ System: For "put" from floor(tokencount(str(PocketCASH), "")÷3) to 1
-----> PocketCASH: Append ","&left(right(str(PocketCASH), LoopIndex×3), 3)
--------+ System: tokenat(Text.Text, 0, "") = ","
---------> PocketCASH: Set text to right(PocketCASH.Text, tokencount(PocketCASH.Text, "")-1)
My attempt at solving this:
I tried adding a condition
----+ System: len(str(PocketCASH)) > 3
However when I add this, now all the Money. Disappears whenever I press a button to purchase something in my game. But without this condition the purchasing works fine and the text updates, except with the annoying ,999 Comma before needed.
Can someone help me?
Original Question:
Anyone know how to make a Text_SET, that is a Global variable, have commas in the Text. Like the variable is 10000 so the text displays 10000 now how would I get the text to display 10,000 instead?