View unanswered posts | View active topics It is currently Thu Apr 25, 2024 2:04 am



This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
 Working with Percents Help 
Author Message
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Post Working with Percents Help
I'm working with some Lua code, and need to know how I would do percent(%) like: hitactor.Health = hitactor.Health - "5%";?


Mon Jun 22, 2009 11:15 pm
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Post Re: Working with Percents Help
hitactor.Health = hitactor.Health * 95/100

To figure it out, subtract it from 100, divide by a hundred and multiply.


Mon Jun 22, 2009 11:16 pm
Profile
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Post Re: Working with Percents Help
Thank you, i was just over thinking the problem.


Mon Jun 22, 2009 11:23 pm
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Post Re: Working with Percents Help
This has nothing to do with Lua but your inability to do math.

the answer is very simple, percentage to decimal is just "percent/100", 5% in decimal = 0.05. "of" is the equivalent to "times" in math terms, so 5% of 100 = 0.05*100.

hitactor.Health = hitactor.Health - 5% of hitactor.Health ;
is
hitactor.Health = hitactor.Health - (0.05 * hitactor.Health);
or to cut out a small step:
hitactor.Health = 0.95 * hitactor.Health; (95% of something = something - 5% of it)

what mail said is basically the above 95/100 = 0.95

if you didn't know that then I'm surprised that you are attempting to make/modify some Lua code, not to put you off, completing something you are not so good at is more beneficial than completing something you are good at, but basic maths is basically the only requirement needed to code.


Tue Jun 23, 2009 12:17 am
Profile
User avatar

Joined: Tue Nov 06, 2007 6:58 am
Posts: 2054
Post Re: Working with Percents Help
Cooljoesmith wrote:
Thank you, i was just over thinking the problem.

Explains it.

Also, basic logic is needed to program.


Tue Jun 23, 2009 12:24 am
Profile
Banned
User avatar

Joined: Tue Feb 27, 2007 4:05 pm
Posts: 2527
Post Re: Working with Percents Help
Basic math. It's not even logic. Basic math. You should understand fractions.

This is mind-numbing.


Tue Jun 23, 2009 12:29 am
Profile YIM
User avatar

Joined: Sun May 31, 2009 1:04 am
Posts: 308
Post Re: Working with Percents Help
Math is applied logic :P


Tue Jun 23, 2009 12:47 am
Profile
Banned
User avatar

Joined: Tue Feb 27, 2007 4:05 pm
Posts: 2527
Post Re: Working with Percents Help
And a square is a type of quadrangle. :P


Tue Jun 23, 2009 1:03 am
Profile YIM
User avatar

Joined: Sat Jan 31, 2009 11:34 pm
Posts: 88
Location: The U S of A's
Post Re: Working with Percents Help
I was trying to program it while tired and not thinking clearly...


Tue Jun 23, 2009 7:20 pm
Profile
Banned
User avatar

Joined: Tue Feb 27, 2007 4:05 pm
Posts: 2527
Post Re: Working with Percents Help
Or educated properly.


Tue Jun 23, 2009 8:18 pm
Profile YIM
Moderator Hero

Joined: Sun Dec 24, 2006 11:28 pm
Posts: 868
Location: London Server
Post Re: Working with Percents Help
Was there any need to carry this on? Just shut up, the lot of you.


Tue Jun 23, 2009 9:51 pm
Profile
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 11 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.080s | 15 Queries | GZIP : Off ]