Display Number as Currency (With Commas)

Get help using Construct 2

Post » Thu Aug 06, 2015 10:41 am

Message: aJamDonut can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
May not be relevant anymore, and may not be very good practice but I did this using string functions and created a function out of it. Seems to perform extremely well. I have this on my site, if you could recommend somewhere else to host it that would be great.

http://www.codersonline.net/C2/NumberFormat.zip
Stuff I'm working on:



http://www.jamdonut.com
B
13
S
3
Posts: 88
Reputation: 1,025

Post » Sun Nov 08, 2015 6:53 am

Message: aronduby can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Figured I would share what I wound up with after looking into it a bit more. I'm not sure how it performs compared to the others, but it's working well for my use I guess.I have a one-liner javascript call that I use when I need to do this for websites, so I used the Construct Browser.ExecJS to it.

https://dl.dropboxusercontent.com/u/71308871/c2-formatnumber/FormatNumber.caproj

Code: Select all
Browser.ExecJS("parseInt(" & Function.Param(0) & ", 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,').replace('.00','');")


The regex in there requires a decimal, hence the toFixed. My usage is usually with whole numbers so I remove the addition of the decimal points at the end with the additional replace('.00','') call.
B
7
S
3
Posts: 7
Reputation: 790

Post » Thu Nov 17, 2016 3:41 pm

Hi guys, I´m not sure if this is a good place to ask, but does anyone know a good way to show 1.5 k gold intead of 1500 gold? And change abbreviation as the number goes higher? Also I don´t know exactly how to search this on google, I searched number abbreviation and found this tread.Thanks!
B
11
S
2
Posts: 28
Reputation: 807

Post » Sat Dec 10, 2016 1:53 am

Draconiz717 wrote:Hi guys, I´m not sure if this is a good place to ask, but does anyone know a good way to show 1.5 k gold intead of 1500 gold? And change abbreviation as the number goes higher? Also I don´t know exactly how to search this on google, I searched number abbreviation and found this tread.Thanks!


Let's say you have a variable called GOLD. What I do now, is...

event (If GOLD > 999 & < 10000)
Action (Set text to left(str(GOLD),1))&"."&mid(str(GOLD),1,1))

Something like that. Using lefts and mids is a lot easier than having multiple functions and variables.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 963
Reputation: 10,721

Post » Mon Dec 12, 2016 12:39 pm

@AnD4D thanks for the help, it worked really well. But in a case where the player is accumulating 1000 gold per second, and he has already accumulated over 1 million gold, the "1,20" format doesnt show increase very often due to the income being too small. Do you know a way around this issue, without having to use more decimal points? I have limited space to work with. thanks!
B
11
S
2
Posts: 28
Reputation: 807

Post » Wed Dec 14, 2016 3:08 am

Sorry, I don't know how to show an increase without the addition of more decimal points or an increase in revenue.

I don't believe it's possible. How would it work in the real world?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 963
Reputation: 10,721

Post » Wed Dec 14, 2016 7:26 am

@Draconiz717 It probably wouldn't be very readable but you could use something like sexagesimal or base 64 numbers which would make say 1 trillion into just 7 characters but still show smallest of changes
http://convertxy.com/index.php/numberbases/

If you want a number system with higher base to get even shorter numbers you'd probably have to figure some of it out by yourself or be better at googling than I am.
B
17
S
6
G
1
Posts: 41
Reputation: 1,725

Post » Wed Dec 14, 2016 9:22 pm

@Draconiz717 This could probably come in handy. You can add even more abbreviations to your leisure.

https://dl.dropboxusercontent.com/u/700 ... mbers.capx
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Fri Dec 16, 2016 11:47 am

Thanks @Maukka and @Magistross! It solved my problem! Thank you very much! Cheers
B
11
S
2
Posts: 28
Reputation: 807

Post » Fri Sep 08, 2017 4:49 am

That was extremely helpful space ape. By far a much easier way to show larger numbers. I'll give it a shot and no, threads are never dead!
B
6
S
1
Posts: 2
Reputation: 354

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: dop2000, nahima and 6 guests