# Limiting displayed value to only 4 numbers?

Get help using Construct 2

### » Fri May 17, 2013 2:47 pm

Hi!

I have the following line

<Set Text to "Score: " & Player.Y>

As you can imagine Player.Y is quite a long value.

Is there any way to limit the displayed value to only 4 numbers?
B
10
S
3
Posts: 233
Reputation: 1,537

### » Fri May 17, 2013 2:52 pm

Look at right() and str() system expressions.

right(str(Player.Y),4) will return four rightmost characters of a given string, which is the player's score converted to a string.

Alternatively, you can use modulo operator %:

Player.Y%10000

This will return the last four digits.Mipey2013-05-17 14:54:00
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

### » Fri May 17, 2013 2:59 pm

Thanks Mipey, works great for the last four digits.

I used Left to get the first four digits, but the thing is, the Y value starts off as 3 digits to begin with. So I get 123 and a . at the end of the score in the start, as in 123. . How do I avoid that?Xionor2013-05-17 15:02:14
B
10
S
3
Posts: 233
Reputation: 1,537

### » Fri May 17, 2013 3:04 pm

Oh yeah, then the number is a float. You have to convert it to integer with int(Player.Y).

Actually, your problem should be entirely solved with this int() expression, no need for left or right or modulo, as long as your scores don't get absurdly high.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

### » Fri May 17, 2013 3:09 pm

Thank you Mipey! Works like a charm! Is there any way to give you rep? ^^

Do you have any idea if it's possible to declare an int variable, or are all variables floats?Xionor2013-05-17 15:09:32
B
10
S
3
Posts: 233
Reputation: 1,537

### » Fri May 17, 2013 3:12 pm

Nope, all number variables are floats. But you can always use int(x) to convert them to integers before using them.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155