Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Jared242004
Beginner


Joined: 28 Jul 2004
Posts: 21
Location: Canada

PostPosted: 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
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: 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)}
Reply with quote
Jared242004
Beginner


Joined: 28 Jul 2004
Posts: 21
Location: Canada

PostPosted: 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
Reply with quote
SCORNME
Novice


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

PostPosted: 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)))}
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: 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))}
Reply with quote
Jared242004
Beginner


Joined: 28 Jul 2004
Posts: 21
Location: Canada

PostPosted: Wed Jul 28, 2004 3:27 pm   
 
Thanks Guys that give me what I needed!

I really appreciate this

Jared
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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.
Reply with quote
SCORNME
Novice


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

PostPosted: 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 Sad But I still like reading and learning about them!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net