Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Substitution of a string (not individual words) in an alias.

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

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by DigitalWraith   (2 posts)  Bio
Date Sun 21 Dec 2003 12:26 AM (UTC)
Message
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 ::
Top

Posted by Ian Kirker   (30 posts)  Bio
Date Reply #1 on Sun 21 Dec 2003 12:32 AM (UTC)
Message
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-
Top

Posted by DigitalWraith   (2 posts)  Bio
Date Reply #2 on Sun 21 Dec 2003 01:46 AM (UTC)
Message
-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-
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Sun 21 Dec 2003 09:31 PM (UTC)
Message
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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,735 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.