Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
ferfer
Newbie


Joined: 21 Feb 2004
Posts: 4

PostPosted: Sat Feb 21, 2004 1:42 am   

Help with a trigger
 
Ok, like several others, I'm having a problem with a trigger working in 7.01.

I can post what I have, but it might just be easier to ask how to do it correctly :)

What I want to do is create a trigger that captures text (1 or 2 words) from a mud and then set up clocks. The clocks are working, and if I type in the exact words, I can get my trigger to work, but I can't have a trigger that has 6 different "states" depending on the words.

Here's a sample of what I need to capture:
[ 6]: tonal control visu (note the space at the beginning and this is the beginning of a line, but isn't the end)


I tried: ~[ %9~]~: (%w)(%w) visu ~(*~) as the trig for the first with
#IF ("%1"="tonal" AND "%2"="control") as my condition, but that doesn't seem to work.

Any ideas? I may be completely off track, so just let me know. Also, is there any way to do a trigger for two words (the tonal control case above) and a one word (slash visu)?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Feb 21, 2004 3:18 am   
 
Have a look at the Pattern Matching help topic, which lists all the official zMUD wildcards. As you'll see, %9 isn't one of them.

%w matches any amount of alpha characters, so %w%w or (%w)(%w), assigns all but the last letter of an alphaword to the first %w and the last character to the second %w. Without a space between them, there's no chance of them matching two words.

To match:
[ 6]: tonal control visu
your pattern should be something along the lines of:
%d~]: (%w) (%w) visu

To match any one- or two-word pattern before "visu", it should be something like:
%d~] (*) visu
Reply with quote
ferfer
Newbie


Joined: 21 Feb 2004
Posts: 4

PostPosted: Sat Feb 21, 2004 3:31 am   
 
I've put the space in between (found that earlier and fixed it :) ), I guess the problem I have is that I want to echo something to another window, so if I had:

[ 6]: tonal control visu
I want to echo [ 6]: tonal control visu

BTW: I've got it working on 2 words now (thanks), but is there a way to use the same trig to work for 1 or 2 words? I have it working as 2 separate trigs, but just wondered if I could combine them. Current trig is:

^~ ~[ %1~]~: (%w) (%w) visu ~(*~)

With the value doing something like:
#IF ("%2"="tonal" AND "%3"="control") {#win songs ~[%1~] VIS %upper(%2) %upper(%3)}
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Feb 21, 2004 5:22 am   
 
Why do you insist on using undocumented wildcards? Never mind, it's your script, but you should know that undocumented features don't always continue to work in future versions and it's not a bug when they stop working (the bug is that they work now).

You don't need ~ before spaces.
I already told you how to handle multiple words. Use *. If it's necessary to limit it to one or two words, but not three or four, use #IF. Of course, there's nothing wrong with the two-trigger solution either. That's one trigger for one-word patterns and another trigger for two-word patterns. I've seen some awful kludges from people who insist on trying to squeeze every possibility into a single trigger instead of simply making several to handle different possibilities.

#TR {^ ~[ (%d)~]~: (*) visu } {#IF ((%numwords( %2) = 1) OR (%numwords( %2) = 2)) {#WIN songs {~[%1~] VIS %upper( %2)}}}
Reply with quote
ferfer
Newbie


Joined: 21 Feb 2004
Posts: 4

PostPosted: Sat Feb 21, 2004 6:19 am   
 
Lets see if I can respond again without my computer crashing on me :)

By undocumented wildcard, I assume you mean the [%1] at the beginning of a trigger. I'm using that because I was sent part of these triggers by a friend, and that worked for them. When I tried to use the %d as you suggest, I can't get the trigger to pass the number like I wanted.

My current trig is: ^ ~[ %d~]~: (%w) (%w) visu ~(*~) Which I'd like to match [ 6] tonal control visu and then pass this information to:
#IF ("%2"="tonal" AND "%3"="control") {#win songs ~[%1~] VIS %upper(%2) %upper(%3)}

It puts the tonal in %1 and control in %2, but if I use the %1 instead of the %d, then it works like I want. So where did I mess up? I'm trying to learn the ins and outs of zmud programming, and know that I probably don't have the correct syntax, but that's what this forum is for :)

Also, I don't HAVE to have one trig to do the 1 or 2 words, I was just wondering if it could be done.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Feb 21, 2004 7:15 am   
 
Code:
#TR {^ ~[ (%d)~]~: (%w) (%w) visu} {#IF ("%2"="tonal" AND "%3"="control") {#win songs ~[%1~] VIS %upper(%2) %upper(%3)}}



What is so hard about that put parenthesis around what your trying to capture (%d) = %1 (%w) = %2 (%w) = %3

I also suggest you read the help files for pattern matching I sense LightBulb short circuiting here :P
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Feb 21, 2004 6:13 pm   
 
You wanted a trigger which will match either ONE or TWO words between the [ 6] and visu. I gave you a trigger to do exactly that. All you need to do is copy it character-by-character, with no changes, to the command line. That appears to be giving you trouble, so I can only guess that you're trying to make the trigger in the Settings Editor instead. So, here's a Settings Editor version and I've even removed the %d you don't like and used * instead. I refuse to use undocumented wildcards myself.
Pattern:
^ ~[(*)~]: (*) visu

Value:
#IF ((%numwords( %2) = 1) OR (%numwords( %2) = 2)) {#WIN songs {~[%1~] VIS %upper( %2)}}
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Sat Feb 21, 2004 7:05 pm   
 
quote:
Originally posted by LightBulb

You wanted a trigger which will match either ONE or TWO words between the [ 6] and visu. I gave you a trigger to do exactly that.


Lightbulb - It wasn't explicitly stated but;

It appears to me that he thinks the specific words captured are integral to the trigger(s). Maybe he doesn't want any action taken on '[ 6]: hubish rubish visu', for example.


quote:
Originally posted by ferfer

Also, I don't HAVE to have one trig to do the 1 or 2 words, I was just wondering if it could be done.



ferfer - Yes, this can be done with one trigger, but as Lightbulb said, it wouldn't be easy to read, modify or adapt the next time you looked at it. Separate triggers for each word combination is probably best.

You can use nexela's example to do what you want for the specific example you gave.

Edit: I'm just a slow thinker.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Feb 22, 2004 3:20 am   
 
Yes, I've noticed that ferfer always checks for exact words and perhaps I've misunderstood. In his first post he said that he can get the trigger to work if he uses the exact words and I took it that he wants a solution which doesn't depend on having the exact words.

I'm sorry if I come off a bit rude. I find it frustrating to keep answering a question only to have the same question repeated. I'm sure it's equally frustrating for you, ferfer, to keep getting answers which don't provide the information you're looking for. It's probably best if someone else tries to figure out what you're asking and come up with an answer which will actually help you.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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