Regexp with %name%

Posted by Fuzzybat23 on Mon 13 May 2013 02:45 AM — 5 posts, 19,828 views.

#0
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?
Australia Forum Administrator #1
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.
#2
I'm probably wrong in this, but.. would the trigger look like:

^.*(?i)GetInfo(3).*$
Australia Forum Administrator #3
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.*$

#4
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..