How do I avoid having decimals shown as text?

Get help using Construct 2

Post » Tue Mar 18, 2014 8:39 pm

So i got this variable "Humidity" (im developing a sim game like sim earth..), the problem is, it is a huge number all the time after the ",", like: 45,0193458439672946

I want to let the player track it, but i don't want him to se the ,0193458439672946. How can i do that?
B
66
S
22
G
4
Posts: 360
Reputation: 6,584

Post » Tue Mar 18, 2014 8:56 pm

there are a few ways eg floor(number) int(number) round(number)

see https://www.scirra.com/manual/126/system-expressions
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Tue Mar 18, 2014 9:28 pm

Thanks, it was really easy, shame on me!
B
66
S
22
G
4
Posts: 360
Reputation: 6,584

Post » Tue Mar 18, 2014 10:21 pm

I got another question about performance: should i add round( to the actual number (ex, when humidity is calculated) or only to the counter that displays the number in the UI? will any of them affect performance is some way?
B
66
S
22
G
4
Posts: 360
Reputation: 6,584

Post » Tue Mar 18, 2014 11:39 pm

Danwood wrote:I got another question about performance: should i add round( to the actual number (ex, when humidity is calculated) or only to the counter that displays the number in the UI? will any of them affect performance is some way?


It shouldn't matter at the end I think, do what is the more convenient for you
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Wed Mar 19, 2014 6:33 am

Danwood wrote:I got another question about performance: should i add round( to the actual number (ex, when humidity is calculated) or only to the counter that displays the number in the UI? will any of them affect performance is some way?


It also depends on when and where you are doing the conversion, if you are using humidity in any other calculations (where the decimal points would make a difference), how often you are updating the UI ( hopefully you are only updating thing when they change and NOT every tick...). Converting to it once will only take a tiny amount of time - what you don't want to be doing is converting the same number over and over.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests