![](templates/Classic/images/spacer.gif) |
Ren Beginner
Joined: 04 Apr 2003 Posts: 27
|
Posted: Fri May 30, 2003 9:22 pm
miscelleneous questions |
Hi,
Thanks a lot for all the replies to the questions that I liberally posted last night. I really learnt a lot of new commands and tricks to use.
I've been using Zmud for 2-3 years now, and I still feel like a newbie. :) It doesn't cease to amaze me how much you can do with it, and how ingenious were the people who figured how to do it.
To refrain from clogging up the board with every little question I have though, here's a list of nagging little things which has bothered me for awhile.
What's the difference between trigger on prompt and trigger on newline?
I've seen %* used in some scripts, but I couldn't find mention in the manual about the difference between it and *.
Can I delete classes without deleting the aliases/triggers previously set under them? How do I reclass these settings in the settings editor?
* matches any number of words, %w one. Is there one for say, 2 or 3 words, without using *?
The previous question was asked because I am concerned with speed. Are there any simple guidelines in scripting that I can follow to optimize my client speed?
#co and #cw: I like #cw, because when I have color on a colored background, the coloured background doesn't extend all the way to the end of the screen (despite not having any text to color).
But I don't want to use the * wildcard necessary to color the entire text line when I use #cw.
I'm not sure how to use #pcol, and I'd like to know if I can use it instead of #cw and the * wildcard.
The latest Zmud is really cool in terms of color... it even has pink and indigo! I stumbled on these by accident though. Is there a list of all the colors available on Zmud?
I don't understand the $ pattern matching thing. Can someone give a simple example of how it is essential in a trigger?
Thanks a bunch. :)
- Ren |
|
|
![](templates/Classic/images/spacer.gif) |
Vijilante SubAdmin
![](images/avatars/7230815434153eca6be3ad.gif)
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri May 30, 2003 10:47 pm |
Trigger on Prompt vs Newline. Prompt trigger will test the trigger at the end of a packet irregardless of whether it has a newline. Newline indicate that the trigger is to be tested each time a newline is recieved. In both cases the entire line is compared to the trigger pattern.
%* is a highly hazardous pattern matching wildcard. Like * it matches any number of characters and white space, but also matches special characters such as !@#%&; thus allowing the possibilty of your script being altered. Use the search function on the forums to find references to this wildcard, and the full safety parameters.
Yes you can delete a class without deleting the settings. The settings editor will offer to move settings in a class you are trying to delete. If you let it do that then they will be moved to the root/none class. You can always manually move settings by dragging and dropping.
A largely unknown matching usage, mainly because I found it after revising the help and Zugg never documented it, allows you to place anything inside the (). For example to match 2 words: #TR {(%w %w)} {#ECHO Example '%1'}. Another example is matching 3 words with things in the middle: #TR {(%w has %w {his|her} %w) into a big ball of flame.$} {#ECHO Example '%1'}. Note that not just the wildcard %w is put in the paranthesis, but a number of words and wildcards. This also provide your example of the $ usage. $ is used to match end of line, and line breaks in multiline triggers. The first example matches 2 words anywhere, the second matches a very specific portion of a line. The $ and ^ wildcards are also called anchors, because they lock the pattern to a location in a line.
To cover a few more answers...use the pattern formulas above to handle coloring. #COLOR will color the entire line, #CW will color everything matched by the pattern, and #PCOL will color everything in the range specified. #PCOL's specfic usage is "#PCOL color Xstart Xend", but allows usage of the predefined variables %x1..%x99 to be substitited for Xstart and Xend. So that gives an alternate syntax of "#PCOL color %x1". This is by far the preferred method for coloring.
For a list of colors read the help. I am quite certain that all of the color commands say something about all the forms of color definitions supported. But in any case a full list of MXP/HTML names can be found in the help for the %colorname function, RGB syntax is supported (format is either # or $ folowed by hexadecimal sequence: $ABCDEF) and ANSI naming described in just about all of the coloring commands/functions (if you don't see what your looking for used the related buttons to check the others).
Speed, is a truly tricky question. In terms of speed every trigger must be tested at either end of packet or EOL. Then each trigger matched is executed. In order to accelerate things Zugg changed the execution system to put a trigger on hold when a looping command is encountered and move on to the next matched trigger. Then after all have had a chance it goes to the first that had a loop and executes it, and on down the line. So the best thing for speed is avoid loops if you can. If you can think of a way to do the same thing with 15 variables and builtin functions, do it.
As an historical note tight loops have consumed half of software's computing time for every program on all computers since the first program. Loops in general consumed 90%. The other 10% is setting up for the next loop. |
|
|
![](templates/Classic/images/spacer.gif) |
Ren Beginner
Joined: 04 Apr 2003 Posts: 27
|
Posted: Sat May 31, 2003 12:49 am |
Thanks awfully for that detailed post, Vijilante. :)
Some questions below.
*** I'm sorry, but I still can't see the difference between newline and prompt. Isn't the end of a packet a newline by itself?
What would be a simple example of a trigger for newline and another simple one for prompt?
*** I thought I understood $, but I didn't. Example, I want to colour this sentence which wraps into two lines on my screen.
The psycho clown stabs the long steak knife
into you.
With #co, I just colour the first line, leaving the 'into you.' uncoloured. So I added a $ to include it, but then both lines end up uncoloured now.
*** Is this one pattern
You hear a {terrified|horrified} scream {near|far} from you.
faster or will these four patterns
You hear a terrified scream near from you.
You hear a terrified scream far from you.
You hear a horrified scream near from you.
You hear a horrified scream far from you.
run faster?
- Ren |
|
|
![](templates/Classic/images/spacer.gif) |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sat May 31, 2003 3:21 am |
quote: *** I'm sorry, but I still can't see the difference between newline and prompt. Isn't the end of a packet a newline by itself?
NO. A newline is a specific sequence of characters (either ^M^J or ^J^M). This may occur anywhere within a packet. It advances the cursor to the beginning of the next line.
A prompt is a line which ends without advancing the cursor to the next line. Common examples are
Login questions:
What name will you be known by? {YOUR ANSWER SHOWS UP HERE
instead of on the line underneath)
Character roll questions
Keep this character? (Y/n) {YOUR ANSWER SHOWS UP HERE
instead of on the line underneath)
And, of course, the character prompt with info about hps and the like:
<127/127hp 204/204mn 83/83mv> {YOUR NEXT COMMAND GOES HERE
instead of on the line underneath)
quote: *** I thought I understood $, but I didn't. Example, I want to colour this sentence which wraps into two lines on my screen.
#COLOR applies to a full line. It won't work well with multi-line triggers (none of the color commands will). Use some other command to experiment with multi-line triggers. NOTE: Your example has a space after knife. Leading/trailing spaces do count when they occur in the middle of a multi-line trigger.
#TR {The psycho clown stabs the long steak knife $into you.} {#SAY OUCH!}
quote: *** Is this one pattern...faster or will these four patterns...run faster?
The four individual patterns will run faster.
LightBulb
Advanced Member |
|
|
![](templates/Classic/images/spacer.gif) |
Ren Beginner
Joined: 04 Apr 2003 Posts: 27
|
Posted: Mon Jun 02, 2003 6:10 am |
Awesome, that cleared up everything I asked. :) Thanks.
quote:
The four individual patterns will run faster.
Okay. :)
Am I right in assuming full matches are always the fastest?
Please tell me which of the following is best (in order of speed efficiency), so that I can create my future triggers with these guidelines in mind. :)
Pattern: You hear a {terrified|horrified} scream {near|far} from you.
Pattern: You hear a %w scream %w from you.
Pattern: You hear a
Pattern: (the four complete patterns)
The second one looks really clean to me, and more efficient than four different patterns. But that's just me, and I have no idea how the code works.
- Ren |
|
|
![](templates/Classic/images/spacer.gif) |
Kjata GURU
![](images/avatars/190086853941eff9946d4cf.jpg)
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Mon Jun 02, 2003 12:36 pm |
zMUD has two parsers for triggers: a plain-text one and one that handles wildcards. Triggers that only have text in the pattern will never have to call the second parser (which is slower). Also, zMUD tries to discard a line as not being a match using all of the plain-text first. So, if you have two triggers with wildcards that match the same line, but one has more text than the other, the one with more text should be faster since it would allow zMUD to discard it as not being a match in more lines that the other one.
With that in mind, and knowing that stringlist wildcards within a pattern are optimized to quickly match using hash tables (there is a small overhead when the hash table has to be created for the first time, but from then one it is faster), the order should be (from faster to slower): 4, 1, 2, 3.
Based on the above explanation it seems strange that the third option would be last, but the problem is that since it contains so little text the probability of matching a line other than the one you want is high, which would require some code to check for this in the trigger anyway. If, however, the only two lines that start with "You hear a" in all of the text received from the MUD are these two, then it would be the second fastest option. Also, if the third option had been:
You hear a terrified scream %w from you.
You hear a horrified scream %w from you.
then it would have been faster than the second option and even the first one. You can see that the speed is something relative. It depends on how fast zMUD is able to determine that a trigger's pattern is not a match for the line just received from the MUD.
The speed differences should not be that much. If speed is really critical, then go with the fourth option, but if it is not, then the first option is best.
Kjata |
|
|
![](templates/Classic/images/spacer.gif) |
|
|
|
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
|
|