[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Need help with a simple trigger.

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Need help with a simple trigger.
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1  2 

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Thu 08 Jul 2010 01:27 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Deacla   USA  (42 posts)  [Biography] bio
Date Thu 08 Jul 2010 12:30 AM (UTC)  quote  ]
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
[Go to top] top

Posted by WillFa   USA  (517 posts)  [Biography] bio
Date Wed 07 Jul 2010 08:30 AM (UTC)  quote  ]
Message
\ban? (.+?) scroll\b


Would be a simpler pattern.
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Wed 07 Jul 2010 04:56 AM (UTC)  quote  ]

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
[Go to top] top

Posted by Deacla   USA  (42 posts)  [Biography] bio
Date Wed 07 Jul 2010 04:47 AM (UTC)  quote  ]

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
[Go to top] top

Posted by Deacla   USA  (42 posts)  [Biography] bio
Date Wed 07 Jul 2010 04:20 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 07 Jul 2010 04:07 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Deacla   USA  (42 posts)  [Biography] bio
Date Wed 07 Jul 2010 04:00 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Wed 07 Jul 2010 03:40 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 07 Jul 2010 03:39 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Wed 07 Jul 2010 03:38 AM (UTC)  quote  ]
Message
That regexp fired for me on your test string.

If you want to fire both, make sure they both have "keep evaluating" set.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Deacla   USA  (42 posts)  [Biography] bio
Date Wed 07 Jul 2010 02:47 AM (UTC)  quote  ]

Amended on Wed 07 Jul 2010 02:52 AM (UTC) by Deacla

Message
One last thing. I'm having trouble turning this string into regexp so that it also fires the scroll trigger.

AUCTION: Deacla has put a luminescent mother-of-pearl scroll up for auction. Minimum bid is 100 gp.

I've tried myself and can get it to install but it never fires. any help would be great.

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

edit: this is what i have so far to show you the variable aspects of the string.

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

--

working way to hard to play
[Go to top] top

Posted by Deacla   USA  (42 posts)  [Biography] bio
Date Tue 06 Jul 2010 12:38 AM (UTC)  quote  ]
Message
As promised, here is the Materia Magica Scroll to Spell Translator for Mushclient.

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

--

working way to hard to play
[Go to top] top

Posted by Deacla   USA  (42 posts)  [Biography] bio
Date Mon 05 Jul 2010 08:45 PM (UTC)  quote  ]
Message
That's it right there Twisol. thx very much.

Also i will post a copy of the full code when i get all the scrolls programmed in.

--

working way to hard to play
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Mon 05 Jul 2010 08:37 PM (UTC)  quote  ]
Message
Deacla said:
If it would make it easier to keep the styles by appending the spellname all the way to the end as in this example:

A gnomish miner's bag contains:
(  7) a copper-colored scroll  (new)    IDENTIFY
( 20) a blackjack voucher notated with a little '500' (new)
     a glossy lime scroll  (new)    ARMOR
(  2) an unusual swamp flower
     a nightshade mushroom
     an ivory-yellow papyrus scroll  (new)    BLINDNESS
     a charcoal lambskin scroll  (new)    REVEAL


Yeah, that makes it much easier:

<triggers>
  <trigger
   enabled="y"
   match="^((?:\(\s*\d+\))?\s*(.*?)\s*scroll)\s*(\(new\))$"
   omit_from_output="y"
   regexp="y"
   send_to="14"
   sequence="100"
  >
  <send>ScrollTypes = {
  ["a glossy lime"] = "ARMOR",
  ["an ivory-yellow papyrus"] = "BLINDNESS",
  ["a charcoal lambskin"] = "REVEAL",
  ["a copper-colored"] = "IDENTIFY",
}

for _,v in ipairs(TriggerStyleRuns) do
  ColourTell(RGBColourToName(v.textcolour), RGBColourToName(v.backcolour), v.text)
end

if ScrollTypes["%2"] then
  ColourTell("silver", "black", "\t" .. ScrollTypes["%2"])
end

Note() -- finish the line</send>
  </trigger>
</triggers>

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] 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.


3,885 views.

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]