Consistent Variable Number

Get help using Construct 2

Post » Fri Feb 01, 2013 7:46 pm

Hi there,

Is it possible to make a variable number always have the exact same amount of digits in it including 0's and decimals.

For example, I want a variable that begins as 25.0 and counts down at a regular interval by 0.1. I want it to always have 2 numbers and 1 decimal place.

So it might be 22.2, or 05.3 etc.

Thanks in advance.
Squeemish2013-02-01 19:46:34
B
10
S
4
G
5
Posts: 136
Reputation: 2,977

Post » Fri Feb 01, 2013 7:59 pm

I haven't tried it. When you make a variable and do like that, does it say that it isn't possible?
I don't think thats possible.

But why do you need that ?
B
5
Posts: 55
Reputation: 585

Post » Fri Feb 01, 2013 8:06 pm

I'm taking the values of each digit and applying it to a sprites frame number.

At the moment if the value goes below 10.0 it loses the first digit and messes up my sprites.
B
10
S
4
G
5
Posts: 136
Reputation: 2,977

Post » Fri Feb 01, 2013 9:48 pm

Will this help?

zeropad(number, digits)

Pad number out to a certain number of digits by adding zeroes in front of the number, then returning the result as a string. For example, zeropad(45, 5) returns the string "00045".
B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Fri Feb 01, 2013 9:58 pm

That will help a lot. Thanks for that!
B
10
S
4
G
5
Posts: 136
Reputation: 2,977


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, armaldio, plinkie and 16 guests