|
cxs410 Beginner
Joined: 04 Oct 2005 Posts: 20
|
Posted: Tue Oct 18, 2005 1:35 am
What am I doing wrong.. |
I want to display some info in my status window..
for some reason these lines calculate to 0
#MATH hp_percent {(@cur_hp/@max_hp)*100}
#MATH ave_exp {@experienc/@kills}
any idea what i'm doing wrong here? |
|
|
|
ChrisD Beginner
Joined: 18 Oct 2000 Posts: 18
|
Posted: Tue Oct 18, 2005 2:33 am |
#MATH hp_percent {(@cur_hp/@max_hp)*100}
#MATH ave_exp {@experienc/@kills}
I suspect in your first line the () is getting evaluated to 0.xx and truncated down to 0. Try this instead:
#MATH hp_percent {(@cur_hp*100)/@max_hp}
For the second, check that you have some value in @experience (with an e). Try:
#ECHO Current value of experience is: @experience
#ECHO Current value of kills is: @kills
#ECHO Average experience per kill: @ave_exp
Paste us the results. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Oct 18, 2005 2:35 am |
mathematical operators in ZMud use integer math, which means only the numbers to the left of the decimal point are shown. Given that percentages are always a decimal number between 0 and 1, that means the integer portion of said number will always equal 0.
It's been a little while since I used percentages, so lemme see if I can remember this:
(A * 100) / B?
A = 5, B = 10
(5 * 100) / 10 = 500 / 10 = 50. Yep, that's it.
EDIT: Oh, there's also a function to force zmud to use floating-point math, too. %float() around just one number will keep the decimal for you (it doesn't really apply to your problem, just thought I'd toss it out since we were on the subject.) |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
cxs410 Beginner
Joined: 04 Oct 2005 Posts: 20
|
Posted: Tue Oct 18, 2005 5:34 am |
#MATH hp_percent {((cur_hp*100)/max_hp)/10)}
#MATH ave_exp {@experience/@kills}
those two work, thanks for helping me with the %'s and as for the second one, I'm lame and had the wrong spelling and didn't realize until i read the posts..
Thanks again! |
|
|
|
|
|