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 ➜ General ➜ Help: A trigger using regular expressions that excludes certain things

Help: A trigger using regular expressions that excludes certain things

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


Posted by Kersoix   (11 posts)  Bio
Date Tue 18 Jan 2011 10:21 PM (UTC)
Message
Hi, I would like a trigger that makes a beep when tells are sent to me; however, I would like certain tells to not trigger this.

For example -

ABC tells you: hey. -- this should trigger the sound, but

Gaspode tells you: hey. -- this should NOT trigger the sound, as well as

Duck Man's duck tells you: hey. -- this should NOT trigger the sound.

I've had a great deal of trouble getting the trigger to work properly -- either all 3 examples trigger the beep, or none of them trigger the beep.

I've also has success writing simple triggers using colours and/or beeps.

I've tried the following triggers using regular expressions, but none of them have worked.

^(?!Gaspode|Duckman).* tells you.*$

^.*(?!Gaspode|Duckman) tells you.*$

^.*(?!Gaspode|Duckman) (\w*) tells you.*$

^.*(?!Gaspode|Duckman)tells you.*$

as well as variations with and without spaces at various places.

I'm not sure what I'm doing wrong, or whether this is possible at all, although in the past I did manage to get something like this working before. I just can't recall how, ever since I accidentally deleted my previous version of the MUD.

Would appreciate a simple answer to the above, since as you can tell I'm ok at simple but fail at anything more complex.

Cheers.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 19 Jan 2011 09:43 AM (UTC)
Message
By far the simplest way is to ignore the look-behind negative assertions you seem to be playing with and just script the decisions.

For example, match on:


* tells you: *


(This is NOT a regular expression).

Then send to script, and in the script test if %1 (the person doing the telling) is in a list of exclusions.

eg.


exclusions = {
  Gaspode = true,
  Duckman = true,
-- more here
  }

-- play sound if NOT in table:

if exclusions ["%1"] == nil then
  Sound ("ding.wav")
end -- if



- Nick Gammon

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

Posted by Kersoix   (11 posts)  Bio
Date Reply #2 on Wed 19 Jan 2011 04:22 PM (UTC)

Amended on Wed 19 Jan 2011 04:27 PM (UTC) by Kersoix

Message
Thanks, Nick. I'm trying out what you said, but I'm not quite sure I got it right. Well, it's not working out yet.

I've attached a screenshot here... could someone take a look please?

http://www.flickr.com/photos/98525667@N00/5369803767/

Thanks.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 19 Jan 2011 08:39 PM (UTC)
Message
I can test more easily if you simply use the inbuilt copying rather than taking screen-shots.

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


Also please post the MUD output you are testing against. For example:


Duck Man's duck tells you ...


That won't match (although elsewhere you said Duckman not "Duck Man"). First there is the space between "Duck" and "Man" and also there is the lack of space after "Duck Man" (because of the apostrophe).

So the trigger:


* tells you: *


... would match, but the %1 would be "Duck Man's duck". To really match "Duck Man's duck" (as an exclusion) it would need to be in the table, like this:


exclusions = {
  Gaspode = true,
  Duckman = true,
  ["Duck Man's duck"] = true,
-- more here
  }



Also, matching is case-sensitive.

- Nick Gammon

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

Posted by Kersoix   (11 posts)  Bio
Date Reply #4 on Thu 20 Jan 2011 02:09 AM (UTC)

Amended on Thu 20 Jan 2011 02:10 AM (UTC) by Kersoix

Message
Yeah, you're right, it should be Duck Man, not Duckman. My bad.

Anyways, here's the code you asked for. What happens now is that the trigger still sounds on every tell.


<triggers>
  <trigger
   enabled="y"
   match="* tells you: *"
   match_bold="y"
   match_inverse="y"
   match_italic="y"
   send_to="12"
   sequence="101"
   sound="C:\Program Files\MUSHclient\worlds\Ding.wav"
   other_text_colour="orange"
   other_back_colour="midnightblue"
  >
  <send>exclusions = {
  Gaspode = true,
  ["The Duck Man's duck"] = true,
-- more here
  }
-- play sound if NOT in table:
if exclusions ["%1"] == nil then
  Sound ("ding.wav")
end -- if</send>
  </trigger>
</triggers>


Tells that should sound look like this:

Yase tells you: no, i'm not

Thalic tells you: There's a hole in our group, yes :)

Basically it includes every human being on the MUD.


Tells that should not sound look like this:

The Duck Man's duck tells you: Is it really, dear? Okay, then, I believe you.

Gaspode tells you: Vote for us now!

Basically I don't want tells from these characters on the MUD to make a beep.

Thanks.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 20 Jan 2011 06:24 AM (UTC)
Message

sound="C:\Program Files\MUSHclient\worlds\Ding.wav"


You are still playing the sound on the trigger match. You should change that to "no sound" and then let the trigger decide whether or not to play a sound.

- Nick Gammon

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

Posted by Kersoix2   (3 posts)  Bio
Date Reply #6 on Wed 09 Feb 2011 07:13 PM (UTC)

Amended on Wed 12 Nov 2014 06:14 AM (UTC) by Kersoix2

Message
I wonder if there's a specific directory I have to put the sound file into?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #7 on Wed 09 Feb 2011 07:55 PM (UTC)
Message
If you use backslashes in the sound pathname you are likely to run into trouble. It *does* work but you sometimes need to double or quadruple the number of backslashes, because of the way backslashes are handled in strings.

I suggest putting the sounds into the "sounds" sub-folder under the MUSHclient.exe program (make it if it isn't there already). Then PlaySound at least looks for sound files there (I'm not sure about the Sound function). Then you don't need backslashes.

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


22,431 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.