How Percentage work at expressions?

Get help using Construct 2

Post » Mon Mar 26, 2012 3:17 am

Hello
I want to know how to make percentage work at the expressions interface..

Example:
200 - 20% of it = 160
but don't know how to express it in Construct, so I had to make a longer expression to obtain the same result:
200-(200/(100/20)) = 160
but would be better just to use percentage to obtain the same value..
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Mon Mar 26, 2012 4:03 am

200-(0.2*200)
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Mar 26, 2012 4:32 am

200 * 0.80 = 160
this is the simplest method..
ryuzaki012012-03-26 04:33:34
B
16
S
3
G
1
Posts: 3
Reputation: 954

Post » Mon Mar 26, 2012 4:41 am

[QUOTE=ryuzaki01] 200 * 0.80 = 160
this is the simplest method..
[/QUOTE]
and how did u obtain 0.80?

I don't want to obtain the result 160, it was just an example.

I want a value that is substracted by x% of it.
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Mon Mar 26, 2012 4:44 am

Just remember that a percent is always based on 100.
Nice refresher from khanacademy.org.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Mar 26, 2012 4:47 am

[QUOTE=newt] 200-(0.2*200)[/QUOTE]

with this method first I would need to transform 20 to 0.2(20/100), so at the end would be like my method..
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Mon Mar 26, 2012 4:53 am

Well you can always multiply by 0.01 to get the hundredths position.
So n-(0.01*p*n)
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Mar 26, 2012 4:54 am

[QUOTE=newt] Just remember that a percent is always based on 100.
Nice refresher from khanacademy.org.[/QUOTE]

Ahm.. I know that lol
if hasn't I wouldn't obtained the same result, again, my question is how to use the '%' at the expression.


just to make it clear
there is 3 variables:
life-100
attack-20
defense-10

you hit by 20(atk) - 10(def)% of it = 18
then life reduces to 182.

B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Mon Mar 26, 2012 4:56 am

[QUOTE=newt] Well you can always multiply by 0.01 to get the hundredths position.
So n-(0.01*p*n)[/QUOTE]

50/100 and 50*0.01 is the same.
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Mon Mar 26, 2012 5:07 am

There is no % used in expressions, only as plain text.
The percentage sign "%" otherwise is taken as modulo, the remainder from division.

Correction
% when used in expressions gives you the remainder from division, so yes it is used in expressions, just not for doing percentages.newt2012-03-26 05:11:20
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Next

Return to How do I....?

Who is online

Users browsing this forum: jobel, Timedoor Indones and 21 guests

cron