A little help with a math issue

Discussion and feedback on Construct 2

Post » Sun Jun 14, 2015 6:18 pm

I need to calculate a value and I found some difficulty to create the right equation.

I would like to know the percent of the precision of clicks.

I have the number of the player's clicks and the number of hits. I believe that's correct if I divide them and multiply by 100, including &"%" after, isn't? I tried to use "round" to eliminate decimal numbers, but I didn't get the correct value?

Other doubt: How can I do to prevent "NaN (if player doesn't click in the screen)?

Thanks in advance
B
74
S
14
G
4
Posts: 1,015
Reputation: 8,133

Post » Sun Jun 14, 2015 6:53 pm

If Click_No > 0
-- PrecisionVar = int(100 * Hit_No / Click_No) & "%"
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,283
Reputation: 47,550

Post » Sun Jun 14, 2015 7:28 pm

The right way. Thank you, @Colludium
B
74
S
14
G
4
Posts: 1,015
Reputation: 8,133

Post » Sun Jun 14, 2015 8:25 pm

Any time :). Sometimes I have to leave my self-made problems for a day before I can return and try again.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,283
Reputation: 47,550


Return to Construct 2 General

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests