|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 12:41 am
Formatting some Math... |
I've been reading through prior examples but only found some for Zmud, which doesn't seem to work right in Cmud.. any help with the following would be appreciated!
Goal: When Characters is less than Total Online, color that line, and append the the difference between the two (_on the same line_)
What I've got it doing so far:
# Characters. # Total Online. <<--This shows up as I want it to.
Unseen: # <<-- This shows up in cyan, on its own line
What I want it to do:
# Characters. # Total Online. Unseen:# <<<--This value should ONLY appear if the Total Online is greater than Characters
This is what I did:
<trigger priority="12540" id="1254">
<pattern>(%a) characters. Total online: (%a).</pattern>
<value>#IF ((%1) < (%2)) {#CW "white,mxpgray"}
#MATH unseen %2-%1
#ECHO Unseen: @unseen
</value>
</trigger>
Any suggestions on how to wrangle what I've got, into what I'm hoping for?
With thanks,
Cordir |
|
Last edited by Cordir on Wed Aug 12, 2015 12:47 am; edited 1 time in total |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 12:46 am |
I would suggest %d over %a, but that shouldn't affect things...
the #MATH command is the issue here, sort of
all mathamatical expressions need to be wrapped in parenthesis, so:
#MATH unseen (%2-%1)
or
unseen=(%2-%1)
although, since you have no real need to store the value, i wouldnt bother saving it to a variable at all
#SAYADD { (%2-%1)}
that will append the value to the line |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 12:50 am |
Forgive me, I'm very much a newbie and am not entirely following you.
This:
<trigger priority="12540" id="1254">
<pattern>(%d) characters. Total online: (%d).</pattern>
<value>#IF ((%1) < (%2)) {#CW "white,mxpgray"} #SAYADD { (%2-%1)}
</value>
</trigger>
is resulting in this:
5 characters. Total online: 5.
ERROR: Trigger "(%d) characters. Total online: (%d)." fired but did not compile |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 12:52 am |
wrap the xml in code tags to preserve spacing and the greater than symbols.
you need a semicolon between the two commands. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 1:03 am |
"Code tags" ?
I couldn't find anything in the help files to explain what that is, precisely...
Again, very very VERY much a newbie when it comes to code type things. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 1:08 am |
the code tags are BBC code, to make things look proper on the forum.
Code: |
<trigger priority="12540" id="1254">
<pattern>(%d) characters. Total online: (%d).</pattern>
<value>#IF ((%1) < (%2)) {#CW "white,mxpgray"} #SAYADD { (%2-%1)}
</value>
</trigger> |
should be
Code: |
<trigger priority="12540" id="1254">
<pattern>(%d) characters. Total online: (%d).</pattern>
<value>#IF ((%1) < (%2)) {#CW "white,mxpgray"}
#SAYADD { (%2-%1)}
</value>
</trigger> |
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 1:14 am |
When I use that, zmud is complaining about the < symbol and replacing it with " < " and is not displaying the unseen # .
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 1:32 am |
If all else fails, delete that trigger and enter this one on the command line.
It's the exact same trigger, just not in XML format.
Code: |
#TR {(%d) characters. Total online: (%d).} {#IF (%1<%2) {#CW "white,mxpgray";#SAYADD { (%2-%1)}}} |
Actually, this fixes a mistake i had put in the previous versions. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 3:06 am |
With that, I'm now getting this:
1 character. Total online: 4.(4-1)
It's not doing the math. :(
PS: I deeply appreciate the help! Thank you! |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 3:11 am |
Hmmm... that should work...
Wait, did you say zMUD? this is the CMUD folder. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 3:13 am |
nono. I'm using CMUD (Cmud 3.34). I was only able to find references to math stuff in the ZMud forums :)
|
|
Last edited by Cordir on Wed Aug 12, 2015 3:50 am; edited 1 time in total |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 3:31 am |
Here's what it looks like. (I had to add a small tweek because sometimes it's Characters and sometimes it's Character, depending on the # online.)
http://postimg.org/image/klck8aurn/ |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 4:03 am |
In that case, try this version:
Code: |
#TR {(%d) character{s|}. Total online: (%d).} {#IF (%1<%2) {#CW "white,mxpgray";$temp=(%2-%1);#SAYADD { $temp}}} |
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 4:53 am |
Code: |
[code]P.S. this is how you would wrap your code for the forums.[/code] |
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 4:54 am |
HUZZAH!!
That worked!
Thank you so much for your help! :) |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 5:07 am |
Glad that worked for you.
Still had to use a variable in the end, but $temp is a local variable, so it gets discarded after it is used and not left cluttering up your settings.
Don't forget to delete @unseen! |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 5:22 am |
One last question, I PROMISE... :D
Is there a way to color format the output we've created, so that it matches the rest of the highlighting/color scheme? (Ie, so it's all that white lettering on gray background?) |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 9:01 am |
Just add some MXP color tags:
Code: |
#SAYADD {<color white mxpgray> $temp</color>} |
or better still, just reverse the #SAYADD and the #COLOR commands
#CW will color just the pattern
#CO will color the entire line |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 9:31 am |
I've tried the above, and got this:
ERROR: Trigger "(%d) character{s|}. Total online: (%d)." fired but did not compile
I've also tried:
#IF (%1<%2) {#CW "white,mxpgray";$temp=(%2-%1);#SAYADD #CW "white,mxpgray"{ $temp} |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed Aug 12, 2015 9:39 am |
Code: |
#TR {(%d) character{s|}. Total online: (%d).} {#IF (%1<%2) {$temp=(%2-%1);#SAYADD { $temp};#CO "white,mxpgray"}} |
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Cordir Beginner
Joined: 23 Jan 2011 Posts: 20
|
Posted: Wed Aug 12, 2015 9:59 am |
YAY!!!
That's it! :)
Many thanks, Oh Guru! |
|
|
|
|
|