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 ➜ Plugins ➜ Lua Plugin Help

Lua Plugin Help

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


Posted by Calicoxx   (14 posts)  Bio
Date Sat 19 Sep 2009 03:51 PM (UTC)
Message
So I am trying to make a redirect trigger that when a certain event comes up, it redirects it to Gammon's Chat Redirector. I've added a few things specific to my MUD, but one that I can't seem to figure out goes something like this:

<trigger
	enabled="y"
	match="^[(.*?)\Bonus +(.*?)*$]"
	regexp="y"
	script="redirect"
	sequence="100"
	>
</trigger>


I'm trying to match anything within the [ Bonus + ], but I believe I'm using the wrong character to signify the bonus obtained, or that the syntax in the match is messed up itself.

Any help would be greatly appreciated.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 20 Sep 2009 12:57 AM (UTC)
Message
Can you show an example line of what you are trying to match?

If you are trying to match something actually in square brackets you need to put a backslash in front of them.

eg. to match [Bonus] you would need to match on:


\[Bonus\]


- Nick Gammon

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

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #2 on Sun 20 Sep 2009 01:22 AM (UTC)
Message
Also, in your original example, '$]' probably isn't what you want; the $ is an end-of-line anchor. ']$' is what I expect you meant.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Calicoxx   (14 posts)  Bio
Date Reply #3 on Sun 20 Sep 2009 02:32 AM (UTC)
Message
I'm trying to match anything similar to "[PL Bonus +4]"
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #4 on Sun 20 Sep 2009 03:58 AM (UTC)
Message
Try: \[(.*?)Bonus \+(\d+)\]$
Top

Posted by Calicoxx   (14 posts)  Bio
Date Reply #5 on Sun 20 Sep 2009 05:48 AM (UTC)
Message
I forgot to mention another one, which is [Exp Bonus], where exp can also be several other words.
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #6 on Sun 20 Sep 2009 08:26 AM (UTC)
Message
Then use the following regular expression: \[(.*?)Bonus(?: \+(\d+))?\]$
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #7 on Sun 20 Sep 2009 08:50 AM (UTC)
Message
I'd try this one instead, because I doubt he's interested in the space just before 'Bonus':


\[(?:(.*?) )Bonus(?: \+(\d+))?\]$

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #8 on Sun 20 Sep 2009 08:59 AM (UTC)
Message
Template:regexp Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.

- Nick Gammon

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

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #9 on Sun 20 Sep 2009 01:39 PM (UTC)
Message
Twisol said:

I'd try this one instead, because I doubt he's interested in the space just before 'Bonus':


\[(?:(.*?) )Bonus(?: \+(\d+))?\]$



I was feeling lazy and didn't want to unnecessarily make it more complicated since he presumably would try to take it apart. =p
Top

Posted by Calicoxx   (14 posts)  Bio
Date Reply #10 on Sun 20 Sep 2009 09:36 PM (UTC)
Message
Nah. The first one that was supplied worked, however, there is no plus in the matches for [Exp Bonus], so the plus sign should be omitted. I figured it would look like,

[(?:(.*?) )Bonus]$
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.


33,070 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.