Substitution of a string (not individual words) in an alias.

Posted by DigitalWraith on Sun 21 Dec 2003 12:26 AM — 4 posts, 18,715 views.

#0
If this has been answered before, I do profusely apologise beforehand... although I have not been able to find any similar issues in the forums or in the helpfiles.

Basically, the question is :

How do I substitute a string instead of a sequence of variables when using an alias ?

The situation :

On the mud I play, there's a lot of 'shapeshifting' of your character, and when you do so, it's a real pain to identify who is saying what : "Someone says 'Blahblahblah'" is rather confusing.

What i wanted to do is replace the say command with an alias that basically does :

Someone says ' ::CHARNAME:: "Blahblahblah" '

ie. insert a piece into the say command worked from the client end, and the only way I can see how it works at the moment is to use

alias SAY * * * * * * * * * *
replace with
SAY ::CHARNAME:: %1 %2 %3 %4 %5 etc

which would limit the say alias to 10 variables....

is there a way to just send the subsequent matched variables (the whole string after the say command) to the mud in one foul shot ?

If this can be answered in the positive sense, you will have saved me a lot of hassle and confusion :)

Thanks,

:: Steve ::
#1
Rather than using the normal alias matching system, if you use a regular expression (tick the box marked "Regular Expression") reading:

^say (.*)

To send:

say ::CHARNAME:: %1

The (.*) will match the entire string after the say.
(And the ^ makes sure it only matches at the beginning of a line. I'm not entirely sure if this is necessary, but it works.)

Hope this helps,

-I-
#2
-yay- :) It works :)

Much appreciated - it's already saved me a load of hassles
and confusion - and i only just got it working :)

Once again, thanks Ian :)

-Steve-
Australia Forum Administrator #3
The regular expression solution will work, but your original alias was too complicated anyway. A wildcard can be a string, not just words. Just make it this:

alias SAY *
replace with
SAY ::CHARNAME:: %1