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 ➜ Tips and tricks ➜ Regexp with %name%

Regexp with %name%

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


Posted by Fuzzybat23   (3 posts)  Bio
Date Mon 13 May 2013 02:45 AM (UTC)
Message
In the Connecting section, under the General tab in the Configuration, it says "You can use '%name%' or '%password%' if you wish the name or password supplied above to be inserted. What I'd like to know is, can I use %name% in regexp? I have a number of different muck characters, so what I'm aiming for is a highlight function. Right now I have to use their individual names in triggers, such as:

^.*(?i)Fuzzybat23.*$

which would highlight an entire line anytime "Fuzzybat23" appears.

I'd love to use %name%, like:

^.*(?i)%name%.*$

which should replace %name% with the name of whatever muck char I have connected, but sadly doesn't work. Anyone out there know how I could get something like this to work?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 13 May 2013 12:26 PM (UTC)
Message
No, it's only in the connecting box. However you can find out the player name using GetInfo (3). Then that could be inserted into the regular expression.

- Nick Gammon

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

Posted by Fuzzybat23   (3 posts)  Bio
Date Reply #2 on Mon 13 May 2013 04:39 PM (UTC)
Message
I'm probably wrong in this, but.. would the trigger look like:

^.*(?i)GetInfo(3).*$
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 15 May 2013 10:16 PM (UTC)
Message
No, not like that. You can put variables into triggers if you check "expand variables".

So somewhere in the initialization (world open) you set up a variable, eg.


SetVariable ("playername", GetInfo (3))


Then in the trigger:


^.*(?i)@playername.*$


- Nick Gammon

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

Posted by Fuzzybat23   (3 posts)  Bio
Date Reply #4 on Sun 26 May 2013 08:04 PM (UTC)
Message
I could put everything I need into the world file then?

I'd open up muckworld.mcl in note pad and the first thing I see is:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, January 03, 2013, 8:06 AM -->
<!-- MuClient version 4.84 -->
<!-- Written by Nick Gammon -->
<!-- Home Page: http://www.mushclient.com/ -->
<muclient>
<world

muclient_version="4.84"
world_file_version="15"
date_saved="2013-01-03 08:06:23"
A bunch more variables
> <!-- end of general world attributes -->

Would it go here? ->
SetVariable ("playername", GetInfo (3))

</world>

<triggers
muclient_version="4.84"
world_file_version="15"
date_saved="2013-01-03 08:06:23"
>

And the trigger could go here?
<trigger other_text_colour="silver" sequence="90" repeat="y" regexp="y" match="^.*(?i)@playername.*$" keep_evaluating="y" ignore_case="y" group="Highlighted Words" enabled="y" custom_colour="3"> </trigger>

</Triggers>

Then there's bunches of other code in the world file after this..
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.


19,251 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.