Lua Plugin Help

Posted by Calicoxx on Sat 19 Sep 2009 03:51 PM — 11 posts, 43,819 views.

#0
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.
Australia Forum Administrator #1
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\]

USA #2
Also, in your original example, '$]' probably isn't what you want; the $ is an end-of-line anchor. ']$' is what I expect you meant.
#3
I'm trying to match anything similar to "[PL Bonus +4]"
Netherlands #4
Try: \[(.*?)Bonus \+(\d+)\]$
#5
I forgot to mention another one, which is [Exp Bonus], where exp can also be several other words.
Netherlands #6
Then use the following regular expression: \[(.*?)Bonus(?: \+(\d+))?\]$
USA #7
I'd try this one instead, because I doubt he's interested in the space just before 'Bonus':


\[(?:(.*?) )Bonus(?: \+(\d+))?\]$
Australia Forum Administrator #8
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.
Netherlands #9
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
#10
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]$