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 ➜ Need help with a simple trigger.

Need help with a simple trigger.

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


Pages: 1  2 

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #15 on Wed 07 Jul 2010 03:39 AM (UTC)
Message
Deacla said:

Also how can i put both strings into one trigger so it says either fire on this or this.... or this potentially?


Match on: (this|that)

- Nick Gammon

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

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #16 on Wed 07 Jul 2010 03:40 AM (UTC)
Message
Is that line wrapped/split into two lines when you see it in MUSHclient? If it is, do you know if the server is splitting it, or if MUSHclient is doing the wrapping?

If the server is splitting the line and sending it out that way, then MUSHclient gets it as two separate lines, meaning you need two separate triggers (or one multiline trigger) to match it. If possible, disable the server-side wrapping (you can always configure client-side wrapping in Game -> Configure -> Output) so MUSHclient gets it as one line.

'Soludra' on Achaea

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

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #17 on Wed 07 Jul 2010 04:00 AM (UTC)
Message
It's all one line. It's Mush doing the wrapping.

@Nick: It is firing the trigger but I don't think the correct data is being sent to the ScrollTypes variable. so it doesn't append anything to the end.

--

working way to hard to play
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #18 on Wed 07 Jul 2010 04:07 AM (UTC)
Message

<triggers>
  <trigger
   enabled="y"
   match="^AUCTION\:\s*(.*?)\s*has put(\s*(.*?)\s*scroll) up for auction\. Minimum bid is (.+) gp\.$"
   regexp="y"
   send_to="2"
   sequence="100"
  >
  <send>Fired!
%%1 = %1
%%2 = %2
%%3 = %3
%%4 = %4</send>
  </trigger>
</triggers>


I get:


Fired!
%1 = Deacla
%2 =  a luminescent mother-of-pearl scroll
%3 = a luminescent mother-of-pearl
%4 = 100



Note that %2 has a leading space.

- Nick Gammon

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

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #19 on Wed 07 Jul 2010 04:20 AM (UTC)
Message
Thank you for showing me where i was making the mistake. I changed the trigger to:

^AUCTION\:\s*(.*?)\s*has put\s*(.*?)\s*scroll up for auction\. Minimum bid is (.+) gp\.$

and now it works great. had to remove that leading space. thank you again.

--

working way to hard to play
Top

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #20 on Wed 07 Jul 2010 04:47 AM (UTC)

Amended on Wed 07 Jul 2010 04:51 AM (UTC) by Deacla

Message
Thinking on this further I found I could make it much simpler. I'm trying to get it to match on basically any string with the word scroll in it and match it against the database. this is what i got.

^(.*?)\s*((a|an)\s*(.*?))\s*scroll(.*)$

This still works in the inventory screen, and in bags as it did originally but no where else. How can I describe the following:

^(anything) ((a|an)scrolltype) scroll(anything)$


edit: it does work in some other strings, bot not all other strings.

--

working way to hard to play
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #21 on Wed 07 Jul 2010 04:56 AM (UTC)

Amended on Wed 07 Jul 2010 04:57 AM (UTC) by Twisol

Message
Deacla said:
This still works in the inventory screen, and in bags as it did originally but no where else. How can I describe the following:

^(anything) ((a|an)scrolltype) scroll(anything)$


\b((?:a|an).*? scroll)\b

That'll match and capture "a foo scroll". I'm using a non-capturing group for the a|an, signified by the ?: at the start.

The ^ and $ are start and end anchors. Remove them, and it'll check for it anywhere in a line.

I'm also using \b here, so that it doesn't match "bara foo scrollbaz", for example. The \b stands for 'word boundary'.

'Soludra' on Achaea

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

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #22 on Wed 07 Jul 2010 08:30 AM (UTC)
Message
\ban? (.+?) scroll\b


Would be a simpler pattern.
Top

Posted by Deacla   USA  (42 posts)  Bio
Date Reply #23 on Thu 08 Jul 2010 12:30 AM (UTC)
Message
Thank you all for the help. i ended up changing it again so that it matches on any scroll anywhere that is spelled correctly. I also had to change the data a bit so that I could match a, an, A, and An. didn't realize mush was so case-sensitive. here is the final

(?:.*|)\b(?:an|a|A|An)\b\s*\b(.*? scroll)\b

for the entire updated Materia Magica Scroll to Spell Translator please go here:

https://docs.google.com/leaf?id=0B9VJQA8iYaroM2U2Y2JmOTAtMjg1NS00ZjczLWI3NGMtZjU5YzU0MWQyMmM4&sort=name&layout=list&num=50

--

working way to hard to play
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #24 on Thu 08 Jul 2010 01:27 AM (UTC)
Message
Deacla said:

I also had to change the data a bit so that I could match a, an, A, and An. didn't realize mush was so case-sensitive.


It is the PCRE that is case-sensitive. However you can turn it off (in the trigger dialog) or in the pattern, eg.


(?:(?i)an|a)


The (?i) turns off case-sensitivity inside the brackets.

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


64,905 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

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.