Add commas into score/number

Get help using Construct 2

Post » Sat Jun 14, 2014 1:39 pm

I'm using Spritefonts for my score display and wanted to add commas into my score, like 12,454,343 or 1,234 etc.

I've searched online and found a thread that does focus on this -

viewtopic.php?f=147&t=97394&p=745066&hilit=comma#p745066

But the example there is not working for me, maybe i'm doing it wrong. I'm using the scoring from the Autorunner Template but i can't seem to implement the example into the scoring, either nothing happens or i get issues such as crazy numbers appearing with decimal points.

Does anyone have a suggestions on how i can add commas into my scoring?

Thanks
Image ImageImage
B
7
S
2
G
1
Posts: 91
Reputation: 1,239

Post » Sat Jun 14, 2014 4:48 pm

:)
You do not have the required permissions to view the files attached to this post.
B
6
S
1
Posts: 51
Reputation: 502

Post » Sun Jun 15, 2014 2:11 pm

Thanks for the capx but i have to say that is quite confusing for me, I don't know where to begin :) Does it usually take this amount of events to add commas to a score?

Is it possible to implement this into the Autorunner Template scoring? If so, what exactly do i do? If someone can provide a capx of the commas being added to the Autorunner Template scoring then that would be helpful.
Image ImageImage
B
7
S
2
G
1
Posts: 91
Reputation: 1,239

Post » Tue Jun 17, 2014 12:22 pm

add function object
Image
add variables to the game
Image
copy function
Image
paste function
Image
replace the text statement function.call("function name",numberToDisplay)
Image
tada
Image
B
6
S
1
Posts: 51
Reputation: 502

Post » Tue Jun 17, 2014 4:58 pm

You can also do it in one line using RegexReplace expression (aka, voodoo magic).

Code: Select all
RegexReplace(scoreVar, "\d(?=(\d{3})+$)", "g", "$&,")
B
69
S
28
G
24
Posts: 976
Reputation: 18,737

Post » Tue Jun 17, 2014 10:56 pm

Those are two excellent answers.
B
12
S
3
G
3
Posts: 73
Reputation: 2,647

Post » Wed Jun 18, 2014 2:43 am

B
21
S
5
Posts: 196
Reputation: 1,974

Post » Wed Jun 18, 2014 2:00 pm

Thank you for your responses, it's extremely helpful and appriciate you guys taking time out to help out.
Image ImageImage
B
7
S
2
G
1
Posts: 91
Reputation: 1,239

Post » Wed Jun 18, 2014 4:08 pm

I'm a beginner here and I too was looking at how to insert commas into numbers. Thanks @trultz for the detailed guide into doing this.

I'm curious to @Magistross & @ggibson1 method of doing this. Could you guys go into a bit more detail on how to use this expression please? I've tried inputting this into my score via functions but its not worked for me as nothing happens.

I haven't found many topics that talk about RegexReplace so my knowledge on the matter isn't great, which is probably why it hasn't worked for me.

Thanks.
B
5
S
2
Posts: 126
Reputation: 876

Post » Wed Jun 18, 2014 4:42 pm

well i think i found the problem
You do not have the required permissions to view the files attached to this post.
Last edited by trultz on Wed Jun 18, 2014 8:01 pm, edited 1 time in total.
B
6
S
1
Posts: 51
Reputation: 502

Next

Return to How do I....?

Who is online

Users browsing this forum: rayolf and 23 guests