[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]  General
. . -> [Subject]  Add a multiline trigger with addtriggerex alias?

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Add a multiline trigger with addtriggerex alias?

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


Posted by RichKK   (25 posts)  [Biography] bio
Date Wed 17 Jun 2009 09:52 PM (UTC)  quote  ]

Amended on Wed 17 Jun 2009 09:56 PM (UTC) by RichKK

Message
I'd like to make triggers that match on room descriptions and output my own notes, I know it's possible with world.DoCommand "MakeMultiLineTrigger"

However I plan on doing quite a few of these triggers so I was hoping to move the trigger creation to the command line for speed and less futzing around through the full list of triggers.

I thought one way I could set it up would be similar to an addtriggerex alias but it would also have to parse the clipboard text into a multiline trigger the same way world.DoCommand "MakeMultiLineTrigger" does to the input box... I'd be grateful for any insight.



<aliases>
  <alias
   match="room * "
   enabled="y"
   group=""
   send_to="12"
   sequence="100"
  >
  <send>
AddTriggerEx ("", GetClipboard(), "%1", trigger_flag.Enabled, custom_colour.NoChange, 0, "", "", 0, 0)

</send>
  </alias>
</aliases>
[Go to top] top

Posted by Nick Gammon   Australia  (18,797 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 18 Jun 2009 10:05 PM (UTC)  quote  ]
Message
You might find it easier to use addxml (see http://www.gammon.com.au/forum/?id=7123).

However your core problem, if I understand the question correctly, would be to take a multi-line room description, and turn it into a regular expression.

This would basically involve these things:


  • Converting things (like *, + and brackets) into an escaped form, so that they don't get misinterpreted. A simple string.gsub should do it, with a list of characters you need to escape, and put a backslash in front of them. I think basically any character except A-Z, 0-9 could use such a conversion (excepting newlines). So something like this might do it:

    
    s = string.gsub (s, "[^%d%a%c]", "\\%1")
    


  • Converting newlines to \n in the string

  • Put \A (start of subject) at the front, and \z (end of subject) at the end.

  • Count the newlines, and make that, plus one, be the number of lines to check in the multi-line trigger.


- Nick Gammon

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

Posted by RichKK   (25 posts)  [Biography] bio
Date Reply #2 on Sat 20 Jun 2009 03:45 AM (UTC)  quote  ]

Amended on Sat 20 Jun 2009 03:46 AM (UTC) by RichKK

Message
Bah, I haven't found success yet but thanks for pointing me in the right direction.
[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.


1,218 views.

[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]