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
Malaphus
Novice


Joined: 11 Aug 2003
Posts: 34
Location: USA

PostPosted: Thu Aug 14, 2003 12:39 am   

Replace Problem
 
OK Another question lol...

The MUD I play doesn't send normal tell message (Soandso tells you, 'whatever').

Instead, this is what tells look like:
A quickling appears with a message from Soandso: 'whatever'

Currently I'm gagging this and sending it to antoher window with the following trigger:

Pattern:
A quickling appears with a message from (%w): '(%*)'

Action:
#CAP Chat
#GAG


How would I utilize the replace function (or antoher function) to also change the tell to, "%1 tells you, '%2'"?


Thanks in advance!
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Aug 14, 2003 1:52 am   
 
The command you are looking for is #SUB. It replaces the trigger pattern with its arguments. You might be tempted to do:

DO NOT USE
#TRIGGER {A quickling appears DO NOT USE THIS TRIGGER with a message from (%w): '(%*)'} {#SUB {%1 tells you '%2'};#CAPTURE Chat;#GAG}
DO NOT USE


But, as you can probably guess by now, you shouldn't :P

Since %* can match everything, capturing it and using it in zMUD scripts can create a way for other users to exploit your triggers to do basically anything.

There was a discussion in the beta forum some months back about it and there is only one safe way to use output captured from a %* in a trigger.... that's like this:

#TRIGGER {A quickling appears with a message from (%w): '&%*Message'} {#SUB {%1 tells you '%expand(@Message, 1)'};#CAPTURE Chat;#GAG}

Remember:

Never use (%*) in a trigger pattern and %1, %2, etc to access it. Instead, use &%*varname and then use %expand(@varname, 1) to access it _every_ time you need to in your script. Even if you assign the data to another variable, you must use this method to access the resultant variable.

As an aside, here's a way to completely avoid the issue of the %* in the trigger:

#TRIGGER {A quickling appears with a message from (%w):} {#SUB {%1 tells you};#CAPTURE Chat;#GAG}
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