|
thegto Beginner
Joined: 12 Jun 2007 Posts: 20
|
|
|
|
chaossdragon Apprentice
Joined: 09 Apr 2008 Posts: 168
|
Posted: Fri Nov 24, 2023 4:24 am |
#MATH is depreciated you can just use () to eval
try
$AABB = (100/50)
#SHOW $AABB |
|
|
|
Pauley Beginner
Joined: 17 May 2024 Posts: 17
|
Posted: Fri Jul 05, 2024 10:34 am |
I cannot get #MATH to work, curious as to what I'm doing wrong.
I have a spell's duration which is 2 times your current wisdom + 200 (so the total = X seconds)
I made a trigger to capture my wisdom in the @WIS variable
then I made a IWDUR variable (the spells duration) which contains this:
#MATH (200+@WIS+@WIS)
Let us say for this example that my wisdom is 150, so that the WIS variable is 150 - the math becomes 200+150+150=500 seconds duration
However, when I type #SHOW @IWDUR, the output in the mud is this:
"#MATH (200+150 +150 )"
So it is not doing math on it at all.. |
|
|
|
mikeC130 Apprentice
Joined: 03 Jul 2006 Posts: 110
|
Posted: Fri Jul 05, 2024 10:37 pm |
No, #MATH doesn't do math in cMud - it isn't actually a command any more, so the parser is treating it as just a string of text. It is expanding your variables, but not doing anything with them as the expression is considered a line of text.
Get rid of the #MATH command and just leave the expression (200+@WIS+@WIS) and it should evaluate it.
ETA: It is still in the list of commands, so it *SHOULD* work, but it doesn't seem to in your example and isn't needed in any case, so just leave it off. |
|
|
|
Pauley Beginner
Joined: 17 May 2024 Posts: 17
|
Posted: Sun Jul 07, 2024 7:50 am |
mikeC130 wrote: |
No, #MATH doesn't do math in cMud - it isn't actually a command any more, so the parser is treating it as just a string of text. It is expanding your variables, but not doing anything with them as the expression is considered a line of text.
Get rid of the #MATH command and just leave the expression (200+@WIS+@WIS) and it should evaluate it.
ETA: It is still in the list of commands, so it *SHOULD* work, but it doesn't seem to in your example and isn't needed in any case, so just leave it off. |
Trying this with #ECHO or #SHOW @IWDUR (expecting the final result "500" to be displayed on screen) I find that it still yields "200 150 150" in the mud window
The variable IWDUR contains only this phrase "(200+@WIS+@WIS)" and for some reason refuses to process it in any other way than as just plain text to be displayed in the mud window
Quite possibly i have implemented this in the wrong way
Edit1:
If i type "#SHOW (2+2)" it displays "4"
If I type "#SHOW (200+150+150)" it displays "500"
but here comes the snag, when i type "#SHOW (200+@WIS+@WIS)" it displays "200 150 150"
Edit2:
"#MATH TEST (@WIS+@WIS)" yields "150 150" when I type"#SHOW @TEST" while:
"#MATH TEST {@WIS+@WIS}" yields "150 + 150" when I type"#SHOW @TEST"
How confusing that it doesn't want to compute it, it just displays the numbers as they are
Edit3:
Also trying "#MATH TEST (@WIS*2)" yields "0" with "#SHOW @TEST" - so it's clearly doing something to it, but it fumbles and returns 0 |
|
|
|
Pauley Beginner
Joined: 17 May 2024 Posts: 17
|
Posted: Sun Jul 07, 2024 4:54 pm |
Big oooof
The problem was that the trigger capturing my wisdom also captured one blankspace :3
Works as it should now
Edit:
Changed a %1 to "%s(%n)%s" in the capture trigger to avoid getting the blankspace in the variable, this fixed the problem |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sun Jul 07, 2024 11:43 pm |
The #MATH command has been officially deprecated and made redundant, any equation in parentheses will try to evaluate itself, use nested parenthesis when you need to force order of operations.
using %1 as a wildcard is bad form to begin with, that is a captured variable reference
if you just want a numeric value use the %d wildcard, %n is specifically for signed +/- numbers.
P.S. %trim will remove trailing spaces from both sides |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Pauley Beginner
Joined: 17 May 2024 Posts: 17
|
Posted: Mon Jul 08, 2024 5:38 am |
shalimar wrote: |
The #MATH command has been officially deprecated and made redundant, any equation in parentheses will try to evaluate itself, use nested parenthesis when you need to force order of operations.
using %1 as a wildcard is bad form to begin with, that is a captured variable reference
if you just want a numeric value use the %d wildcard, %n is specifically for signed +/- numbers.
P.S. %trim will remove trailing spaces from both sides |
Thank you for the advice, I'm struggling a bit with navigating all the different stuff and what would be best to use (and there's so much to sift through) |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Mon Jul 08, 2024 10:10 am |
General speaking, there is no real 'best' way to do things, just a bunch of tools in the toolbox
The #HELP command can be used with any command or function to read the help files
#HELP #MATH
#HELP %clip |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Pauley Beginner
Joined: 17 May 2024 Posts: 17
|
Posted: Mon Jul 08, 2024 1:22 pm |
shalimar wrote: |
General speaking, there is no real 'best' way to do things, just a bunch of tools in the toolbox
The #HELP command can be used with any command or function to read the help files
#HELP #MATH
#HELP %clip |
Oh wow, that's incredibly helpful, I spent hours yesterday looking through pages full of commands and all kinds of stuff just trying to find a list of %d, %n, %1, etc to see all my options and what their definitions are |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Mon Jul 08, 2024 11:37 pm |
There is a link to all the wildcard characters in #HELP #TRIGGER
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
sosofa Newbie
Joined: 09 Nov 2024 Posts: 2 Location: Phoenix
|
Posted: Sat Nov 09, 2024 8:51 am |
This sounds amazing as I found it very much useful and informative to be honest. Also, I have gone through this post which definitely helped me out a lot as a new member I am looking forward for more such discussions.
|
|
|
|
|
|