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
rhikdavis
Newbie


Joined: 21 Feb 2011
Posts: 3
Location: US

PostPosted: Mon Feb 21, 2011 3:23 pm   

chat window syntax
 
Hello,

I'm playing a mud with an unusual chat display and would like the syntax to make a window for it....its not really as cut and dry as other muds....here are the outputs,


P8 (Merlin): "hi krom" (This is a realm wide chat)


Merlin says, "hi krom" (This is a local chat)

I would like to add a timestamp to each line as well.

Thanks
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Mon Feb 21, 2011 5:10 pm   
 
You want to look into the #TRIGGER and Introduction to Triggers. The %time function will also be helpful.
_________________
Asati di tempari!
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Feb 21, 2011 6:08 pm   
 
Like Tech has sort of implied, the power of CMUD (and zMUD before it) is in their ability to adapt to a wide-array of output forms, even semi-randomized output as well. What this means is that, if you have a basic knowledge of triggers, it really doesn't matter what the output is, you can create a trigger to capture it.

In identifying how to capture a line in a pattern, you need to identify a couple of things:

1) Static vs. Variable
What parts of the line are always the same and what parts of it are changing? Static portions of the line are parts of the pattern that you can put in verbatim into the pattern. For instance, in a pattern of:
Merlin says, "hi krom"

one would presume that, even though your MUD is sort of odd in its chat system, according to you, that [says, "] and ["] is a static portion of the line. Thus, when we make our eventual pattern, we will see this, word-for-word in our pattern.

Some parts of the pattern are variable. With really complex pattern matching, often using regex, we may find that we have a lot of variable portions to the line. Thankfully, for most things, we don't need regex and can use ordinary zScript pattern matching which also covers a wide array of variability in pattern matching. What are the variable parts of the pattern above?

One assumes that [Merlin] is the name of the person saying something, and that this will change from person to person. We also have [hi krom] which is the actual chat message itself.

2) Variable Pattern Matching
So now we've recognized the variable parts of the pattern we need to match, how do we do it? This is where CMUD manages to help you create triggers and scripts no matter how "oddball" your MUD's output is. There's a whole page on Pattern Matching which you should definitely bookmark as a reference.

In order to know which pattern matching script helps us though, we need to identify the parts that make up our variables. Let's start with [Merlin].

Merlin is a name, and, if your MUD is like other MUDs in regards to names, then the name can only contain alpha characters with the possibility of an apostrophe ['] or, possibly, a hyphen [-] thrown in. So, we have three possibilities we need to match: variable amount of alpha characters, apostrophes, and hyphens. This sort of problem is perfectly suited to using the range pattern matcher. You can put multiple pattern matchers within a pair of square brackets [] in order to indicate that you're attempting to match any of them, thus: [%w+'-] tells CMUD that you want to match something that has any mix of multiple alpha characters, apostrophes and hyphens. Thus we have the first part of our pattern:
[%w+'-] says, "

But what about the message? [hi krom] is simple enough, but messages can contain almost anything. It must require some insanely complex amount of pattern matchers in a range, right? Actually, not really. We can just use *. Use of * should be limited, because it matches EVERYTHING and one of the fundamental rules of Pattern Matching is Limiting. i.e. we want to limit the number of possible matches down to only what we want it to match. Once it begins to match other things we run into problems. However, in this case, the combination of our static pattern and our limited matching of just a name (we can further limit it with a beginning of line symbol) means that we can be fairly confident that our use of * to match any message sent by the other person will be alright. Thus, we have
^[%w+'-] says, "*"

as our first pattern. From there, your capture trigger becomes just like any standard capture trigger you may have seen in the tutorials. Hopefully my post will help you be able to design the necessary patterns for the remainder of your channels.

One last note, sometimes you'll need to match something in a line which zScript recognizes as something for its pattern matching. For instance, the parentheses in the following:
P8 (Merlin): "hi krom"

zScript uses those in order to "capture" information from the pattern to be used in the trigger. Obviously we want to match those, not necessarily capture them. In order to do this, zScript provides an escape symbol which tells the parser that we want to match what follows the escape symbol, not use it as part of the pattern matching. That symbol is [~] Thus, to match () we would use ~(~).

I hope this helps!
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Feb 21, 2011 11:21 pm   
 
In addition to all the above, you can automatically set any individual window to include a timestamp to every line, by a setting in the Options within that window. Click Options, then within thie Preferences window click Session, and then the Scrollback tab. There is a checkbox for Show Timestamps. This can be set separately for each window.
Reply with quote
rhikdavis
Newbie


Joined: 21 Feb 2011
Posts: 3
Location: US

PostPosted: Tue Feb 22, 2011 8:29 pm   
 
Thanks for the help...still greek, but its a start. Wish there were more examples...surely someone has done this before. Mr. Green
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Feb 22, 2011 8:40 pm   
 
One of the reasons for trying to get you to do it on your own is because you alone know best the sorts of stuff you need to match. The information you gave us was too brief for me to feel comfortable that a pattern I give you will cover all circumstances. For instance, in:

P8 (Merlin): "hi krom"

What's P8? Is it the channel name? Is it always the same for that channel? Etc? Are there any little differences like inclusion of language that can make it look different? These little differences are what separate good patterns from bad ones.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
rhikdavis
Newbie


Joined: 21 Feb 2011
Posts: 3
Location: US

PostPosted: Fri Mar 04, 2011 8:42 pm   
 
Hi, thanks...good points....I don't mind trying to figure it out, but it'd be great if there were some examples to look at...

Anywho....the 8 changes...the character name between ()'s changes of course...

I'm going to work on it some more.

Thanks again...
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Mar 05, 2011 6:37 pm   
 
So, if you look at the pattern matching page I listed, how would you compensate for a variable number? I already gave you the syntax for matching a name Razz
_________________
Listen to my Guitar - If you like it, listen to more
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