
Jared242004 Beginner
Joined: 28 Jul 2004 Posts: 21 Location: Canada

Posted: Wed Jul 28, 2004 12:38 am
help for #math Dividing 
I am trying to make a trigger that will divide for me and put the answer into a variable. I have tried the recommened
#math var1 {@var2/@var3}
also
#math var1 (@var2/@var3)
also
#math var1 @var2/@var3
Please help me, What am I doing wrong.
Thanks
Jared 



Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia

Posted: Wed Jul 28, 2004 12:58 am 
Var2 divided by Var3 probably equates to a fraction, and then rounded down to 0. Unless you use %float, zmud works by integers.
#math Var1 {%float(@var2)/%float(@var3)} 



Jared242004 Beginner
Joined: 28 Jul 2004 Posts: 21 Location: Canada

Posted: Wed Jul 28, 2004 1:45 am 
ok got that now, how about multiplying and disarding the fraction?
I had to make the trigger
#math Var1 {%float(@var2)/%float(@var3)}
#math var1 {var1*100}
I wanted to turn it into percentage to report it and there is too many numbers now. I get a value of ex. 42.567891234543%
How do I turn it into say 42.5 after doing to multiply.
Thanks for the Help so far it worked great after I added the
#math var1 {var1*100}
Thanks
Jared 



SCORNME Novice
Joined: 25 Jul 2004 Posts: 48 Location: aka Falan

Posted: Wed Jul 28, 2004 4:54 am 
Jared242004 wrote: 
#math Var1 {%float(@var2)/%float(@var3)}
#math var1 {var1*100}
I wanted to turn it into percentage to report it and there is too many numbers now. I get a value of ex. 42.567891234543%
How do I turn it into say 42.5 after doing to multiply. 
Would this work?
#MATH var1 {%format(2,(%eval(@var1*100)))} 



Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia

Posted: Wed Jul 28, 2004 8:20 am 
Not quite, Scornme. You have an extra set of parentheses in your command.
#MATH var1 {%format(2,%eval(@var1*100))} 



Jared242004 Beginner
Joined: 28 Jul 2004 Posts: 21 Location: Canada

Posted: Wed Jul 28, 2004 3:27 pm 
Thanks Guys that give me what I needed!
I really appreciate this
Jared 



LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA

Posted: Wed Jul 28, 2004 5:45 pm 
The simple way to get percentages is to do the multiplication first.
#MATH var1 {100 * @var2/@var3)
If you want to include tenths of percents:
#MATH var1 {1000 * @var2/@var3)
#MATH var1 %float( @var1/10) 

_________________ LightBulb
Senior member
Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious. 



SCORNME Novice
Joined: 25 Jul 2004 Posts: 48 Location: aka Falan

Posted: Thu Jul 29, 2004 4:35 am 
Danlo wrote: 
Not quite, Scornme. You have an extra set of parentheses in your command.
#MATH var1 {%format(2,%eval(@var1*100))} 
Thanks, Danlo. I wasn't sure if the %eval needed () around it. I wish I could download zMUD at work so I could test scripts during my downtime. Alas, I don't have Admin access But I still like reading and learning about them! 




