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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  how to implement a zmud function "#cap number"

how to implement a zmud function "#cap number"

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


Posted by Fred   (11 posts)  [Biography] bio
Date Mon 16 Jan 2006 06:35 AM (UTC)
Message
I want to capture certain lines after a trigger fired.
such as whenever a trigger is fired, it will send the next 5 lines to notepad. Is there any way to implement it?
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Mon 16 Jan 2006 09:48 PM (UTC)
Message
The simplest thing is to make a multi-line trigger, like this:


<triggers>
  <trigger
   enabled="y"
   lines_to_match="6"
   match="^whatever matches first line\n.*\n.*\n.*\n.*\n.*\n\z"
   multi_line="y"
   regexp="y"
   send_to="1"
   sequence="100"
  >
  <send>Your response here</send>
  </trigger>
</triggers>


What this is doing is matching the "trigger text" as the first part of the regular expression, followed by 5 lots of .* (anything) followed by a newline.

- Nick Gammon

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

Posted by Fred   (11 posts)  [Biography] bio
Date Reply #2 on Tue 17 Jan 2006 01:09 AM (UTC)
Message
thanks,it works
but I still have a question.
actually i want to save those lines into a file.
if i use send to log. seems like it will write to file
after i disconnet.. then i try function to write the %0
into file. it always say something like the string is incomplete...
Any idea?
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Tue 17 Jan 2006 03:19 AM (UTC)
Message
Did you quote it? Like: "%0"

- Nick Gammon

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

Posted by Fred   (11 posts)  [Biography] bio
Date Reply #4 on Tue 17 Jan 2006 04:10 AM (UTC)
Message
Ya, I did
even Note("%0") doesnt work
[Go to top] top

Posted by Nick Gammon   Australia  (23,016 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Tue 17 Jan 2006 04:25 AM (UTC)

Amended on Tue 17 Jan 2006 04:26 AM (UTC) by Nick Gammon

Message
First, you can simplify the trigger like I do below with:


(.*\n){5}


This makes it more obvious that we want exactly five of the extra lines.

Next, in Lua you can have multi-line literals, so this will work:


<triggers>
  <trigger
   enabled="y"
   lines_to_match="6"
   match="^whatever matches first line\n(.*\n){5}\z"
   multi_line="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Note [[%0]]</send>
  </trigger>
</triggers>


The sequence [[ something ]] is a multi-line literal, which can include linebreaks.

An alternative, if you don't want to use Lua (for some reason hehe), is to call a script, like this (in VBscript):


sub mytrigger (name, line, wildcards)
  Note wildcards (10)
end sub


Now the issue of newlines within a quote goes away as this is a variable, not a quoted string.

- Nick Gammon

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

Posted by Fred   (11 posts)  [Biography] bio
Date Reply #6 on Tue 17 Jan 2006 04:33 AM (UTC)
Message
cool
thx for your help.
[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.


15,125 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 HostDash]