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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
kompressormight
Newbie


Joined: 06 Mar 2007
Posts: 6

PostPosted: Mon Jun 11, 2012 2:55 am   

basic #math
 
I am having a heap of trouble with #math, so any help is really appreciated.

Basically, the idea here is to take given variables x y and z and multiply them each by individual rates and sum the totals. When I do a flat #math even with correct input it doesn't seem to even result in an echo.

How do I incorporate math into my script and call the result, possibly defining a new variable based on the result?
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Jun 11, 2012 3:48 am   
 
#MATH only exists for backwards compatibility with old zmud scripts. In cmud, doing math is as easy as enclosing your expression in parentheses. For example:
Code:
variable = (@x * rate1 + @y * rate2 + @z * rate3)
Reply with quote
kompressormight
Newbie


Joined: 06 Mar 2007
Posts: 6

PostPosted: Mon Jun 11, 2012 4:24 am   
 
wow, awesome. a much simpler and more elegant solution than i expected. this is perfect, thank you :)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Jun 11, 2012 1:24 pm   
 
FYI, the #MATH command never produced an echo--it only set the value of a variable. But the newer parentheses syntax is much more convenient. In fact, if you just wanted to display the result without saving it to a variable, you can do:
Code:
#SHOW (@x * rate1 + @y * rate2 + @z * rate3)
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Fri Jun 15, 2012 10:10 pm   
 
Geez, ban these spammers already. Enough is enough.
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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