Data Realms Fan Forums http://45.55.195.193/ |
|
Working with Percents Help http://45.55.195.193/viewtopic.php?f=73&t=15498 |
Page 1 of 1 |
Author: | Cooljoesmith [ Mon Jun 22, 2009 11:15 pm ] |
Post subject: | 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%";? |
Author: | mail2345 [ Mon Jun 22, 2009 11:16 pm ] |
Post subject: | 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. |
Author: | Cooljoesmith [ Mon Jun 22, 2009 11:23 pm ] |
Post subject: | Re: Working with Percents Help |
Thank you, i was just over thinking the problem. |
Author: | robolee [ Tue Jun 23, 2009 12:17 am ] |
Post subject: | 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. |
Author: | mail2345 [ Tue Jun 23, 2009 12:24 am ] |
Post subject: | 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. |
Author: | ProjektTHOR [ Tue Jun 23, 2009 12:29 am ] |
Post subject: | Re: Working with Percents Help |
Basic math. It's not even logic. Basic math. You should understand fractions. This is mind-numbing. |
Author: | Kyred [ Tue Jun 23, 2009 12:47 am ] |
Post subject: | Re: Working with Percents Help |
Math is applied logic |
Author: | ProjektTHOR [ Tue Jun 23, 2009 1:03 am ] |
Post subject: | Re: Working with Percents Help |
And a square is a type of quadrangle. |
Author: | Cooljoesmith [ Tue Jun 23, 2009 7:20 pm ] |
Post subject: | Re: Working with Percents Help |
I was trying to program it while tired and not thinking clearly... |
Author: | ProjektTHOR [ Tue Jun 23, 2009 8:18 pm ] |
Post subject: | Re: Working with Percents Help |
Or educated properly. |
Author: | Seraph [ Tue Jun 23, 2009 9:51 pm ] |
Post subject: | Re: Working with Percents Help |
Was there any need to carry this on? Just shut up, the lot of you. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |