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.
 Entire forum ➜ MUSHclient ➜ General ➜ Repeating on the same line

Repeating on the same line

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


Posted by Larkin   (278 posts)  Bio
Date Fri 24 Jun 2005 02:31 PM (UTC)

Amended on Fri 24 Jun 2005 02:33 PM (UTC) by Larkin

Message
I haven't figured out the trick to triggering a pattern multiple times in a single line. I'm attempting to check the contents of my pocketbelts and store the values in a table. I can make three or four triggers or come up with a complex regular expression to do this, so that's not my question. Can anyone tell me how to match on a very simple expression that just repeats on the same line? My trigger isn't doing it.

Sample output to match on:
You check the contents of your 5 pocketbelts:
   3959  spices               5  kombu               63  coltsfoot
     36  kafe                53  galingale           49  pennyroyal
     50  faeleaf             51  calamus             61  marjoram
      2  colewort            51  myrtle             120  chervil
     50  arnica


My trigger:
<triggers>
  <trigger
   enabled="y"
   keep_evaluating="y"
   match="(\d+)\s+(\w+)"
   regexp="y"
   repeat="y"
   send_to="12"
   sequence="100"
  >
  <send>Note("You have %1 of %2.")</send>
  </trigger>
</triggers>


My results:
You check the contents of your 5 pocketbelts:
You have 5 of pocketbelts.
   3959  spices               5  kombu               63  coltsfoot
You have 3959 of spices.
     36  kafe                53  galingale           49  pennyroyal
You have 36 of kafe.
     50  faeleaf             51  calamus             61  marjoram
You have 50 of faeleaf.
      2  colewort            51  myrtle             120  chervil
You have 2 of colewort.
     50  arnica
You have 50 of arnica.



Edit: monospace isn't monospaced? Code is, though. Heh.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Fri 24 Jun 2005 06:25 PM (UTC)
Message
Your trigger will MATCH multiple times on a line (turn on highlighting, you'll see), however it will only send to the script (and thus, your note) once per line.

So, you'll have have three triggers (one for three items, one for two items, one for a single item), of course, you could also just have a single trigger with three items in it (where two are optional).

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2526

Theres a post in there from Nick with an example of the optional wildcards.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #2 on Fri 24 Jun 2005 07:31 PM (UTC)
Message
Thanks. At least I'm able to get it to match with only one trigger then.

Can anyone (Nick) explain why it only sends to the script once? Other than highlighting or gagging, what's the use in matching multiple times and not executing each time. I mean, I can easily cause stack overflows with infinite loops in other places, so why not here? :)
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.


13,181 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.