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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Is there a limit on a trigger's length?

Is there a limit on a trigger's length?

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


Posted by Keegan   USA  (5 posts)  [Biography] bio
Date Mon 09 Nov 2009 01:05 AM (UTC)

Amended on Mon 09 Nov 2009 01:06 AM (UTC) by Keegan

Message
I've been messing with the chat redirector to move all battle related text to a new window. One of my triggers has this line:

match="^.+ (parries your attack.|has some big nasty wounds and scratches.|is at death's door.|is showing a few grazes.|fails to stun you and you sneak in an attack!|has some big nasty wounds and scratches.|is in perfect health.|has quite a few wounds.|needs a hospital.|has a few minor scratches.|dodges your attack.|is bleeding lightly.|has some small wounds and bruises.|is showing a few battle scars.|has some big nasty wounds and scratches.|has some very nasty wounds.|is gravely injured.|failed to kick dirt into your eyes!|has some big nasty wounds and scratches.)$"


At the rate I'm going, this line will grow quite a bit more.
Will this cause any problems? Should I keep it going, or split it into more triggers?

Here's the entire script I have so far if anyone is interested. It's for Aardwolf.



<?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 -->

<!--
Edit plugin and change "chat_world" variable to be the name of the 
world you want chats to go to.
-->

<muclient>
<plugin
   name="Battle_Redirector"
   author="Nick Gammon/keegan"
   id="cb84a526b476f69f403517da"
   language="Lua"
   purpose="Redirects battle messages to another world"
   date_written="2007-06-30 10:45:35"
   requires="4.08"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Redirects chats to the specified world.

Add or modify "chat" triggers to capture different sorts of message.

Change the variable "chat_world" to be the name of the world chats are to go to.
]]>
</description>

</plugin>

<!--  Triggers  -->

<triggers>

  <trigger
   enabled="y"
   match="^Your .+ [\d+]$"
   regexp="y"
   omit_from_output="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

  <trigger
   enabled="y"
   match="^.+ you. [\d+]$"
   regexp="y"
   omit_from_output="y"
   script="redirect"
   sequence="100"
  >
  </trigger>

    <trigger
   enabled="y"
   match="^You dodge .+ attack.$|^You blend perfectly with your surroundings and avoid .+ attack.$"
   regexp="y"
   omit_from_output="y"
   script="redirect"
   sequence="100"
  >
  </trigger>
  
      <trigger
   enabled="y"
   match="^[Fighting\: .+"
   regexp="y"
   omit_from_output="n"
   script="redirect"
   sequence="100"
  >
  </trigger>  
  
    <trigger
   enabled="y"
   match="^.+ (parries your attack.|has some big nasty wounds and scratches.|is at death's door.|is showing a few grazes.|fails to stun you and you sneak in an attack!|has some big nasty wounds and scratches.|is in perfect health.|has quite a few wounds.|needs a hospital.|has a few minor scratches.|dodges your attack.|is bleeding lightly.|has some small wounds and bruises.|is showing a few battle scars.|has some big nasty wounds and scratches.|has some very nasty wounds.|is gravely injured.|failed to kick dirt into your eyes!|has some big nasty wounds and scratches.)$"
   regexp="y"
   omit_from_output="y"
   script="redirect"
   sequence="100"
  >
  </trigger>
  
</triggers>

<!--  Script  -->


<script>
<![CDATA[
chat_world = "battles"
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

end -- function redirect 

]]>
</script>


</muclient>
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #1 on Mon 09 Nov 2009 01:21 AM (UTC)
Message
Not sure about trigger match text size limits but I would make separate triggers for each of those.

I'd make a template trigger with everything set to what I want all the triggers options to be and then copy and paste as many as I need into the plugin then modify each ones match field.
[Go to top] top

Posted by Blainer   (191 posts)  [Biography] bio
Date Reply #2 on Mon 09 Nov 2009 01:28 AM (UTC)

Amended on Mon 09 Nov 2009 02:44 AM (UTC) by Blainer

Message
 <trigger
   enabled="y"
   match="^.+ (parries your attack.|has some big nasty wounds and scratches.|is at death's door.|is showing a few grazes...)$"
   regexp="y"
   omit_from_output="y"
   script="redirect"
   sequence="100"
  >

So instead of the above I do this:
<trigger
   enabled="y"
   match="^.+ parries your attack.$"
   regexp="y"
   omit_from_output="y"
   script="redirect"
   sequence="100"
></trigger>
<trigger
   enabled="y"
   match="^.+ has some big nasty wounds and scratches.$"
   regexp="y"
   omit_from_output="y"
   script="redirect"
   sequence="100"
></trigger>

My template trigger would look like this:
<trigger
   enabled="y"
   match="^.+$"
   regexp="y"
   omit_from_output="y"
   script="redirect"
   sequence="100"
></trigger>
[Go to top] top

Posted by Keegan   USA  (5 posts)  [Biography] bio
Date Reply #3 on Mon 09 Nov 2009 03:21 AM (UTC)
Message
I will do that then. It'd be cool if there could be more than one match line in a trigger declaration, but it'd have to have a way to know if it was an and/or etc... Thanks
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 09 Nov 2009 05:16 AM (UTC)
Message
I don't think there is any particular limit - I seem to recall someone had one a while back that matched against 1000 names. However it isn't necessarily the quickest or easiest-to-maintain way of going about it.

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


14,062 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]