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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Multi-line triggers in Dummy Windows

Multi-line triggers in Dummy Windows

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


Posted by Tsheller   USA  (14 posts)  Bio
Date Fri 05 Sep 2008 06:13 AM (UTC)

Amended on Fri 05 Sep 2008 06:14 AM (UTC) by Tsheller

Message
Thanks to the wonderful FAQ, I've worked out the details of my first 'plugin' that does -almost- everything I've wanted it to do. Big thanks to Nick for the help.

I know this is a really stupid question, but hopefully its easy for someone to answer.

I currently have an alias to turn off and on the two triggers I am using for my plugin, but I would also like to echo in my window that I have done such, just for completeness sake.

One of the aliases looks as follows:

<alias
name="chatsoff"
match="chatsoff"
send_to="12"
enabled="y"
sequence="100"
>
<send>
EnableTrigger ("chats_trigger1", false)
EnableTrigger ("chats_trigger2", false)

</send>
</alias>

What would I need to add to make it echo a simple message saying 'chats window has been turned off', I am only assuming at this point that the send_to="12" is referring to the lua scripting stuff built into MUSCHclient..
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #1 on Fri 05 Sep 2008 06:22 AM (UTC)

Amended on Fri 05 Sep 2008 06:23 AM (UTC) by WillFa

Message
Note("Chats are disabled.")


(world.Note() for non Lua scripts)
Top

Posted by Tsheller   USA  (14 posts)  Bio
Date Reply #2 on Fri 05 Sep 2008 06:36 AM (UTC)
Message
I knew it was easy, regardless, you rock my socks.
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #3 on Fri 05 Sep 2008 07:08 AM (UTC)
Message
You're welcome. :) And, send_to="12" means you have "Send to: Script" selected.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #4 on Fri 05 Sep 2008 07:12 AM (UTC)
Message
The 'world.' part is optional for most script engines. MUSHclient tells the Windows Script Interface that "world" is the default namespace, so in most cases (eg. VBscript) you can omit it. An exception (in VBscript) is Execute because there is a VBscript Execute function.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Tsheller   USA  (14 posts)  Bio
Date Reply #5 on Fri 05 Sep 2008 07:24 AM (UTC)

Amended on Fri 05 Sep 2008 08:16 AM (UTC) by Tsheller

Message
Yeah, its working beautifully. Until we have scrolling miniwindows, the dummy window will work really well. I am not even sure if I will use a miniwindow even if it becomes available because I have had such a tough time with it.

This may be the wrong forum, but is there a somewhat easy way to replace the dummy window with a miniwindow?

Also, I've been having a bit of trouble. I'm not sure if its just a limitation of the presented output, but when the group command is called, I am only able to (currently) detect the . denoting the last member of the group, then its a blank line, then the prompt. Something like this:

A crazy-eyed woman [******] (guarding) (guarded), leading:

a wheat-haired man [******] (guarding),
a comely-faced man [******] (guarded),
a golden-haired man [******],
a lithe man [******].

<prompt>

It also has the quirk of capturing everything until the first timer of group executes, I am fairly sure just making it also send the group command when I type chatson will be an easy work around though.

So, is there a better way I could be using triggers to deal with the blank lines. I've included the plugin thusfar below.


The code



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 30, 2007, 10:48  -->
<!-- MuClient version 4.13 -->

<!-- Plugin "Chat_Redirector" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Chat_Redirector"
   author="Nick Gammon"
   id="cb84a526b476f69f403517da"
   language="Lua"
   purpose="Redirects Things and Notifies to Another window"
   date_written="2007-06-30 10:45:35"
   requires="4.08"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Redirects Triggered Info to another Window named soichats
]]>
</description>

</plugin>

<!--  Triggers  -->

<triggers>
<!-- Captures Notify message and sends it to dummy world via redirect script -->
  <trigger
   name="chats_trigger1"
   enabled="y"
   match="^[(.*?)$"
   regexp="n"
   script="redirect"
   sequence="100"
  >
  </trigger>

<!-- Captures Triggering Group message and toggles milti_line_chat trigger if applicable -->
  <trigger
   name="chats_trigger2"
   enabled="y"
   match="^(.*?) leading\:$"
   regexp="y"
   omit_from_output="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="n"
   match="*"
   script="redirect"
   omit_from_output="y"
   name="multi_line_chat"
   sequence="10"
  >
  </trigger>


</triggers>

<!-- Aliases -->
<aliases>
  <alias
   name="chatson"
   match="chatson"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
EnableTrigger ("chats_trigger1", true)
EnableTrigger ("chats_trigger2", true)
EnableTrigger ("multi_line_chat", true)
EnableTimer ("group", true)
Note("Chats are Enabled.")

</send>
  </alias>

  <alias
   name="chatsoff"
   match="chatsoff"
   send_to="12"
   enabled="y"
   sequence="100"
  >
  <send>
EnableTrigger ("chats_trigger1", false)
EnableTrigger ("chats_trigger2", false)
EnableTrigger ("multi_line_chat", false)
EnableTimer ("group", false)
Note("Chats are Disabled.")

</send>
  </alias>

</aliases>
<!-- End Aliases -->

<!-- Timers -->
<timers>
  <timer 
      name="group"
      enabled="y" 
      second="10.00" 
      omit_from_output="y"
      >
<send>
group
</send>
  </timer>
</timers>


<!--  Script  -->


<script>
<![CDATA[
chat_world = "soichats"
local first_time = true

function redirect (name, line, wildcards, styles)

  -- try to find "chat" world
  local w = GetWorld (chat_world)  -- get "chat" world

  -- if not found, try to open it
  if first_time and not w then
    local filename = GetInfo (67) .. chat_world .. ".mcl"
    Open (filename)
    w = GetWorld (chat_world)  -- try again
    if not w then
      ColourNote ("white", "red", "Can't open chat world file: " .. filename)
      first_time = false  -- don't repeatedly show failure message
    end -- can't find world 
  end -- can't find world first time around

  if w then  -- if present
    for _, v in ipairs (styles) do
      w:ColourTell (RGBColourToName (v.textcolour), 
                    RGBColourToName (v.backcolour), 
                    v.text)  
    end -- for each style run
    w:Note ("")  -- wrap up line

  end -- world found

  -- if ends with quote, end of multi-line chat
  if line:sub (-1) == '"' then
    EnableTrigger ("multi_line_chat", false)  -- no more lines to go
  else
    EnableTrigger ("multi_line_chat", true)  -- capture subsequent lines
  end -- if

  -- if ends with . end of multi-line chat
  if line:sub (-1) == '.' then
    EnableTrigger ("multi_line_chat", false)  -- no more lines to go
  else
    EnableTrigger ("multi_line_chat", true)  -- capture subsequent lines
  end -- if 

end -- function redirect 

]]>
</script>
</muclient>
Top

Posted by WillFa   USA  (525 posts)  Bio
Date Reply #6 on Fri 05 Sep 2008 08:54 AM (UTC)
Message
  match="^[(.*?)$"
   regexp="n"


That won't work. It looks like half of a regular expression, but regular expressions aren't turned on.

Also, the ^ in the first position means to match at the start of the line. none of your sample output actually starts with a "[", although with Regular Expressions turned on, you'd need to escape it, "[" so that it literally means an open bracket. With Regular expressions, brackets are reserved for classes. [0-9] means any single digit in that range, for example.

Check out the Regular Expression Syntax link on the main forum page. http://www.gammon.com.au/mushclient/regexp.htm

"^([^[]++)[\*++]\((?:guarding|guarded)?[ ,\.])+(?:leading\:)?$"

Is a pattern that should match your sample output.

The trigger 'multi_line_chat' grabs everything and anything. Would you like to be a little more discriminating? :)

Ummm... I'm tired, sorry if that's not as helpful as I'd like.

Top

Posted by Tsheller   USA  (14 posts)  Bio
Date Reply #7 on Fri 05 Sep 2008 10:19 AM (UTC)

Amended on Fri 05 Sep 2008 10:57 AM (UTC) by Tsheller

Message
*mutter* This is what I get when scripting at 4am ;)

No, you are being a great help. Fact is, what that other trigger is trying to grab isn't important, I was just trying to get output just to see the darn thing work, but now that it is, fixed that part. The text that it is looking to match is

[A yellow-painted volkswagon beetle (The Autobots) is online.

Again, when either someone shows me or I figure it out, I will probably try to do some formatting to arrange those who have recently notified by their group (The Autobots) of those who notified within the last hour or something.

As far as the multi_line_chat goes, I am not sure how else to grab everything while still being discriminating. It -would- be neat to grab names, and then arrange them by their health with some sub headings like.

Group:

Healthy (at and 4 stars)
-
Injured (below 4 stars)
-
Critical (at and below 2 stars)
-

Oh yeah, even though its a dummy window, is there a way to actually Replace what is in the screen rather than append? Its looking more and more like I need to take another stab at Miniwindows, but this is working for now.

-- Added

The regular expression you gave me is returning..

Line   40: Error "Failed: unmatched parentheses at offset 44" processing regular expression "^([^[]++)[\*++]\((?:guarding|guarded)?[ ,\.])+(?:leading\:)?$" (trigger not loaded)
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #8 on Fri 05 Sep 2008 03:09 PM (UTC)
Message
He made a small typo: ^([^[]++)[\*++]\((?:guarding|guarded)?[ ,\.]\)+(?:leading\:)?$
Top

Posted by Tsheller   USA  (14 posts)  Bio
Date Reply #9 on Sat 13 Sep 2008 04:15 AM (UTC)
Message
Gonna resurrect this since I've had only marginal results with my own testing.

I have having some trouble with the above plugin. It doesn't seem to be discreet enough to only capture the desired text. I am not sure if the problem is just that I do not have anything more exact to trigger on or if there is a better way. Anyone have some ideas or advice on how to make this work better?

thanks.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #10 on Sun 14 Sep 2008 12:14 AM (UTC)
Message
What I suggest you do is turn on Trace mode (Game menu -> Trace).

That will tell you when triggers / aliases fire. Judging by what I have seen above maybe one of your triggers should be normally disabled, and only enabled when necessary.

Using trace, you can say to yourself "that trigger fired, but it shouldn't have - why is that?", or "that trigger didn't fire, but it should have - why is that?".

- Nick Gammon

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


25,186 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.