Add a multiline trigger with addtriggerex alias?

Posted by RichKK on Wed 17 Jun 2009 09:52 PM — 3 posts, 15,912 views.

#0
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>
Amended on Wed 17 Jun 2009 09:56 PM by RichKK
Australia Forum Administrator #1
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.

#2
Bah, I haven't found success yet but thanks for pointing me in the right direction.