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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Using multiple named wildcards in a trigger
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Using multiple named wildcards in a trigger

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


Posted by Silco69   Australia  (3 posts)  [Biography] bio
Date Sun 27 Sep 2015 02:25 AM (UTC)

Amended on Sun 27 Sep 2015 03:27 AM (UTC) by Silco69

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

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 27 Sep 2015 08:52 AM (UTC)
Message
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.

- Nick Gammon

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

Posted by Silco69   Australia  (3 posts)  [Biography] bio
Date Reply #2 on Sun 27 Sep 2015 01:43 PM (UTC)

Amended on Mon 28 Sep 2015 10:52 PM (UTC) by Nick Gammon

Message

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

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 28 Sep 2015 11:01 PM (UTC)

Amended on Tue 29 Sep 2015 12:54 AM (UTC) by Nick Gammon

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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


2,466 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]