Author |
Message |
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
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 |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
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 |
|
|
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Re: Working with Percents Help
Thank you, i was just over thinking the problem.
|
Mon Jun 22, 2009 11:23 pm |
|
|
robolee
Joined: Fri May 11, 2007 4:30 pm Posts: 1040 Location: England
|
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 |
|
|
mail2345
Joined: Tue Nov 06, 2007 6:58 am Posts: 2054
|
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 |
|
|
ProjektTHOR
Banned
Joined: Tue Feb 27, 2007 4:05 pm Posts: 2527
|
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 |
|
|
Kyred
Joined: Sun May 31, 2009 1:04 am Posts: 308
|
Re: Working with Percents Help
Math is applied logic
|
Tue Jun 23, 2009 12:47 am |
|
|
ProjektTHOR
Banned
Joined: Tue Feb 27, 2007 4:05 pm Posts: 2527
|
Re: Working with Percents Help
And a square is a type of quadrangle.
|
Tue Jun 23, 2009 1:03 am |
|
|
Cooljoesmith
Joined: Sat Jan 31, 2009 11:34 pm Posts: 88 Location: The U S of A's
|
Re: Working with Percents Help
I was trying to program it while tired and not thinking clearly...
|
Tue Jun 23, 2009 7:20 pm |
|
|
ProjektTHOR
Banned
Joined: Tue Feb 27, 2007 4:05 pm Posts: 2527
|
Re: Working with Percents Help
Or educated properly.
|
Tue Jun 23, 2009 8:18 pm |
|
|
Seraph
Moderator Hero
Joined: Sun Dec 24, 2006 11:28 pm Posts: 868 Location: London Server
|
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 |
|
|
|