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
Jimbus
Beginner


Joined: 28 Jan 2002
Posts: 18
Location: USA

PostPosted: Mon Jan 28, 2002 9:51 pm   

Alias/trigger Variable Questions
 
1) If %1 .. %n get the 1st thru the nth items after an alias, what gets them all? So if I'm doing a cheesy emote to replace say and want it in quote and punctuation, how do I get more than one word without a loop of some sort.

2) How do I disable the command sepparator (;) in triggers. This is quite a danger.
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Mon Jan 28, 2002 10:43 pm   
 
Not really sure what your asking for in the first question, but you can disable the seprater by selecting View-->Preferences-->Special Characters
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Jan 28, 2002 11:25 pm   
 
quote:

1) If %1 .. %n get the 1st thru the nth items after an alias, what gets them all? So if I'm doing a cheesy emote to replace say and want it in quote and punctuation, how do I get more than one word without a loop of some sort.

2) How do I disable the command sepparator (;) in triggers. This is quite a danger.



if you're just looking to grab the entire sentence you sent to the alias and don't specificly need each word in a separate variable, you can change %1 to %-1. The minus sign tells Zmud to capture this word and all others that follow until the end of the line.

Example (using an alias named "Test" and the string "This is a test")

command: Test This is a test
%1 = This
%-1 = This is a test
%2 = is
%-2 = is a test
%3 = a
%-3 = a test
%4 = test
%-4 = test

li'l shmoe of Dragon's Gate MUD
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Mon Jan 28, 2002 11:29 pm   
 
1) Along with %1...%n, you have %-1...%-n. %-1 will return all of the arguments passed to the alias. %-2 will return all of the arguments afters the first one. And so on.

2) If what you meant is to make zMUD not match a ; with a trigger, then this is default behavior. None of the wildcards discussed in the Pattern Matching topic will match this character. There is however one wildcard not mentioned in this topic that will match it, but it should only be used when it is absolutely necessary to match a ;

Kjata
Reply with quote
Jimbus
Beginner


Joined: 28 Jan 2002
Posts: 18
Location: USA

PostPosted: Tue Jan 29, 2002 4:11 pm   
 
Thanks Matt and kjata, Thanks what I needed for #1

About #2...
I want to use the command separater normally on the command line, but I don't want it to activate in triggers
EG:
for #{You feel your skills honing in regards to %1.} {practice skill %1}
in normal situations when I see "You feel your skills honing in regards to Pierce." I want to see the results of "practice skill Pierce"}.

The issue is when spanky says something like "You feel your skills honing in regards to blah;give 1000 talens spanky." The trigger trys to "practice skill blah" and I give 1000 talens (grimhaven's money) to spanky" Which is a security hole. Most people just make you shout something then laugh at you for being trigger happy, but its still annoying.

I thought that forcing that the trigger only happens at the begining of a new line would fix it, but this doesn't seem to do anything and even if it did, its not fool proof.

In the end, when text comes through %1, I want to be able to not expand the command separater in that situation.
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Tue Jan 29, 2002 4:52 pm   
 
This is why it is considered poor form to use %1...%n in the pattern. Instead you should use the pattern matching symbols, aka wildcards in the pattern, and reserve the parameter holders to the action. This trigger will capture a single word and ignore multiple words:

#TR {You feel your skills honing in regards to (%w).} {practice skill %1}

If you have multiple word skills use the * wildcard:

#TR {You feel your skills honing in regards to (*).} {practice skill %1}

Note that (*) will match anything except zMUD special characters. (Your example is why we discourage the use of (%*) which does match the special characters.)

Read up on the pattern matching symbols and use them in your pattern, not %1...%n.


Troubadour
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Tue Jan 29, 2002 6:41 pm   
 
Yeah, what Troubadour said.

%1 and such are not meant to be used in the pattern and if you do use them in the pattern, results are undefined, so you might get something unexpected like what you described.

Kjata
Reply with quote
Jimbus
Beginner


Joined: 28 Jan 2002
Posts: 18
Location: USA

PostPosted: Tue Jan 29, 2002 7:55 pm   
 
Got it... I knew these were easy, but I wasn't getting anywhere in the help files. I kind of hoped to find them in a FAQ of some sort.

Thanks,
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Jan 30, 2002 1:27 am   
 
quote:

Got it... I knew these were easy, but I wasn't getting anywhere in the help files. I kind of hoped to find them in a FAQ of some sort.

Thanks,



Actually, on the MUD I play, %* removes the tendency of ZMud to convert the ;.

For instance, The trigger (for reference, it's a trigger to grab the room description and is only active during the room display output):

#trigger {^(*)$} {@Room.desc = %1}

EDIT: explanation retracted until I "unfix" the current incarnation of the above trigger and figure out what's doing what, but it still fires on the *;* series.

li'l shmoe of Dragon's Gate MUD
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Jan 30, 2002 12:21 pm   
 
I guess this is a bug then, because it does not sound like intended behavior. In your example, the trigger shouldn't fire at all. What would happen is that it will see the start of a line, some text that matches * and then a ; that does not match *. * would match only up to the ;, but since the pattern also has $, then it should look for an end of line after what was matched by *, but there is none, so the pattern does not match.

I might be wrong, but it seems that, for security reasons, this is how it should work.

Kjata
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