Weird Text bug

Get help using Construct 2

Post » Wed Feb 24, 2016 2:11 pm

Hey,
I've a pretty weird bug showed at the text object.

I set the Text Object to - Health & " / " & Max_Health
so it will show - 5 / 5

The enemy's doing 0.1 Damage to the Player, so it should obviously show - 4.9 / 5
But my Problem is, it shows really weird numbers, like - 4.9000000000000089 / 5 or something like that.
I created a second Text object, what only shows the Health, and there it shows 4.9

Does anyone have the same problem and knows a solution?
Or is this a known bug?


Kind regards
B
9
S
2
Posts: 50
Reputation: 700

Post » Wed Feb 24, 2016 3:19 pm

@vendara - That's weird, I tried to remake your event and did not find anything wrong with the text object setting it's text to variables or variables have any problem. It must be the event you used to subtract the Health Variable or to put it simply, If there is a bug or an incorrect event then the problem must be when the enemy do some damage with the player.

Try to use "Round" native expression to remove the decimal places when you cast damage. Are you using the "float" expression by any chance?
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
67
S
22
G
90
Posts: 1,125
Reputation: 60,036

Post » Wed Feb 24, 2016 3:55 pm

chadorireborn wrote:@vendara - That's weird, I tried to remake your event and did not find anything wrong with the text object setting it's text to variables or variables have any problem. It must be the event you used to subtract the Health Variable or to put it simply, If there is a bug or an incorrect event then the problem must be when the enemy do some damage with the player.

Try to use "Round" native expression to remove the decimal places when you cast damage. Are you using the "float" expression by any chance?



There is nothing wrong with the events.
I also tried to recreate it in a other Project, and it didn't happened.
It even happens when I'm using floor or round, II already tried that.
B
9
S
2
Posts: 50
Reputation: 700

Post » Wed Feb 24, 2016 4:03 pm

vendara wrote:
chadorireborn wrote:@vendara - That's weird, I tried to remake your event and did not find anything wrong with the text object setting it's text to variables or variables have any problem. It must be the event you used to subtract the Health Variable or to put it simply, If there is a bug or an incorrect event then the problem must be when the enemy do some damage with the player.

Try to use "Round" native expression to remove the decimal places when you cast damage. Are you using the "float" expression by any chance?



There is nothing wrong with the events.
I also tried to recreate it in a other Project, and it didn't happened.
It even happens when I'm using floor or round, II already tried that.


It happened when you used round() too? That doesn't seem possible.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Wed Feb 24, 2016 4:11 pm

gumshoe2029 wrote:
vendara wrote:
chadorireborn wrote:@vendara - That's weird, I tried to remake your event and did not find anything wrong with the text object setting it's text to variables or variables have any problem. It must be the event you used to subtract the Health Variable or to put it simply, If there is a bug or an incorrect event then the problem must be when the enemy do some damage with the player.

Try to use "Round" native expression to remove the decimal places when you cast damage. Are you using the "float" expression by any chance?



There is nothing wrong with the events.
I also tried to recreate it in a other Project, and it didn't happened.
It even happens when I'm using floor or round, II already tried that.


It happened when you used round() too? That doesn't seem possible.


That's what i mean - weird bug :D
B
9
S
2
Posts: 50
Reputation: 700

Post » Wed Feb 24, 2016 5:18 pm

Displaying floating point numbers can be troublesome in Javascript. The decimal part often doesn't have an absolute binary representation, which leads to your "weird" behavior. You should always format your numbers before displaying them when you are dealing with decimals. Too bad Construct doesn't offer expressions to deal with that. One way to do it would be to parse the string representation of your numbers, and limit the output to the wanted decimal places.

Here's a crude example : https://dl.dropboxusercontent.com/u/700 ... ormat.capx
B
76
S
31
G
27
Posts: 1,015
Reputation: 20,790


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 20 guests