Using multiple named wildcards in a trigger

Posted by Silco69 on Sun 27 Sep 2015 02:25 AM — 4 posts, 18,118 views.

Australia #0
Hello!

I feel like I'm reviving an old thread here...

I'm trying to match a string of text in a named wildcard, but the pattern that this text can appear means I must use the named capturing group more than once ie:

match="^ * (Her|His|Its) skin (?J)(?P<strength>(has been hardened to a rock-like form|has been hardened with numerous layers of a mineral-like substance)), although (.*).$|^ * (Her|His|Its) (?P<strength>(has tiny threads of metal running all over it)), although (.*).$"

I've entered the (?J) as mentioned in a previous thread which fixed the Error "Failed: two named subpatterns have the same name at offset..." error but it still seems to mess up when it triggers.

[string "Plugin"]:2592: bad argument #3 to 'ArraySet' (string expected, got nil)
stack traceback:
[C]: in function 'ArraySet'
[string "Plugin"]:2592: in function <[string "Plugin"]:2555>

Using Mushclient Version 4.94

-- This is what i'm trying to capture --

* His has tiny threads of metal running all over it, although the stomach seems not to be covered.

or

* Tiny threads of metal run criss-cross all over your skin, although the head seems not to be covered.
Amended on Sun 27 Sep 2015 03:27 AM by Silco69
Australia Forum Administrator #1
Please post the actual trigger:

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.
Australia #2

<trigger
   enabled="n"
   keep_evaluating="y"
   match="^ \* (Her|His|Its) skin (?J)(?P<strength>(has been hardened to a rock-like form|has been hardened with numerous layers of a mineral-like substance|has been hardened with a chalk-like substance|is covered with several layers of a chalk-like substance|has been covered with a thin layer of chalk|is covered with a thick metal net|has metal bands running all over it, forming a kind of net|is covered with a thin metal net|has been covered with a thin, net-like metal coating|has solidified into a rubberous form|is made elastic with numerous layers of a rubber-like substance|has been treated with a latex-like substance|is covered with several layers of a latex-like substance|has been covered with a thin layer of latex)), although (.*)\.$|^ \* (His|Hers|Its) (?P<strength>has tiny threads of metal running all over it), although (.*)\.$"
   script="shield_up"
   name="prot_ccc"
   ignore_case="y"
   regexp="y"
   lowercase_wildcard="y"
   omit_from_output="n"
   sequence="20"
  >
  </trigger>


[EDIT] Code tags added.
Amended on Mon 28 Sep 2015 10:52 PM by Nick Gammon
Australia Forum Administrator #3
I can't see what your script is doing, but with this test script:


function shield_up (name, line, wildcards)
  require "tprint"
  tprint (wildcards)
end -- shield_up


With your test data I get:


1=""
2=""
3=""
4=""
5="His"
6="has tiny threads of metal running all over it"
7="the stomach seems not to be covered"
0=" * His has tiny threads of metal running all over it, although the stomach seems not to be covered."
"strength"="has tiny threads of metal running all over it"


In other words, the "strength" wildcard is the one to use. The other wildcards (1, 2, 3, 4) are empty because they didn't match.