|
kompressormight Newbie
Joined: 06 Mar 2007 Posts: 6
|
Posted: 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? |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: 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) |
|
|
|
|
kompressormight Newbie
Joined: 06 Mar 2007 Posts: 6
|
Posted: Mon Jun 11, 2012 4:24 am |
wow, awesome. a much simpler and more elegant solution than i expected. this is perfect, thank you :)
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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) |
|
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: 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
-------------------------------- |
|
|
|
|
|