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 ➜ Suggestions ➜ AddTrigger, Repeat on same line.

AddTrigger, Repeat on same line.

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


Posted by Jiffies Maloye   Sweden  (1 post)  Bio
Date Sat 08 Feb 2003 10:34 PM (UTC)
Message
The scripting function AddTrigger misses a key function .. repeat on same line .. am i the only one missing it ?
i need it for my scripting >.< (using a who command on a muck to gather nicks and then generating a regex trigger (Name,Name1,Name2), thus the repeat on same line would be nice to have)

//Jiffies ( nilspe_80(AT)hotmail(dot)com )
Top

Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Reply #1 on Sun 09 Feb 2003 01:20 AM (UTC)
Message
Check at:

http://www.gammon.com.au/scripts/function.php

Specifically this one:

http://www.gammon.com.au/scripts/function.php?name=AddTriggerEx

The help files that come with Mushclient are incomplete do to a lot of things getting added and changed rapidly in the last half dozen versions.
Top

Posted by Cino   Australia  (17 posts)  Bio
Date Reply #2 on Thu 22 Jun 2006 02:56 PM (UTC)
Message
I have recently attempted to make a similar thing, a plugin to colour names that generates triggers on startup using any number of lists each stored in a variable (user may manage and modify easily via a few alias commands).

I had been using Repeat on same line in testing, using triggers made via the GUI, and now in the move to AddTriggerEx I also find myself unable to locate this particular flag.

My trigger_flag table contains,
Enabled=1
OmitFromLog=2
OmitFromOutput=4
KeepEvaluating=8
IgnoreCase=16
RegularExpression=32
ExpandVariables=512
Replace=1024
LowercaseWildcard=2048
Temporary=16384

which is the same as is listed in the documentation.

Suppose following with a SetTriggerOption("thetrigger","repeat",1) should be good enough?

Just curious to know if I have missed something. :)
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 22 Jun 2006 10:22 PM (UTC)
Message
Quote:

Suppose following with a SetTriggerOption("thetrigger","repeat",1) should be good enough?


Yes, this is one way of doing it. It is not in the list of flags handled by AddTrigger or AddTriggerEx.

This is an example of how the client has evolved. If I was writing another way today I would stick to one simple system of setting options.

If you want to add triggers (or other things) quickly and easily you might consider using ImportXML:

http://www.gammon.com.au/scripts/doc.php?function=ImportXML

The processing for ImportXML is exactly the same as what MUSHclient uses to load triggers (etc.) when loading up a world, and thus will support all available options.


ImportXML [[
<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="blah"
   regexp="y"
   repeat="y"
   sequence="100"
  >
  </trigger>
</triggers>
]]


The advantage of this is it is more readable, all options are supported, and you do the whole thing in one operation.

Of course, the parts that change will be done as variables (eg. using string.format).

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #4 on Thu 22 Jun 2006 10:27 PM (UTC)
Message
Here is an example of using ImportXML with variables, and checking the import:


matchtext = "cake"
sequence = 90

assert (ImportXML (string.format ([[
<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="%s"
   regexp="y"
   repeat="y"
   sequence="%i"
  >
  </trigger>
</triggers>
]], 
  matchtext,   -- what to match on
  sequence     -- sequence number
  )) == 1)     -- should import exactly one thing


- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 22 Jun 2006 10:59 PM (UTC)

Amended on Fri 23 Jun 2006 03:57 AM (UTC) by Nick Gammon

Message
Follow this link for a method to simplify the whole thing. This takes a technique described in the Lua manual, to make a function take "named" arguments (by putting them in a table). This simplifies doing your own AddTrigger, and allows for all possible options:

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

The example at the end shows how you can call MyAddTrigger using any of the possible keywords supported by the XML code. It automatically turns true and false into "y" and "n" to make it look a bit more natural. It also handles the cases of something like a quote symbol being inside (say) the match text.


- Nick Gammon

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

Posted by Cino   Australia  (17 posts)  Bio
Date Reply #6 on Fri 23 Jun 2006 07:08 AM (UTC)
Message
Thanks, that has been a great help.

But I have run into a problem with the imported triggers.

My alias for changing the other_text_colour and the back colour gsubs them into the particular list variable, and uses
SetTriggerOption("%<list>","other_text_colour",utils.split("%<args>"," ")[1])


An example of use, name:colour aList aFrontColour aBackColour

The names are only coloured by the new colours if the plugin is reloaded (so the triggers are rebuilt from ImportXML using the new colours recently stored in the variable).

I don't quite understand, as I can modify the match field of the triggers, and the recently added or removed name is coloured (or is not as required) without having to reload anything.

Since I have the same issue trying to modify the other colours of triggers in the world space, I suspect the problem lies in my SetTriggerOption calls. I am not sure how else to pass the colour if that is incorrect.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #7 on Fri 23 Jun 2006 07:54 AM (UTC)
Message
You may have found a bug. Can you copy the offending trigger (the one that doesn't work) and paste the XML code here please?

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #8 on Fri 23 Jun 2006 08:25 AM (UTC)
Message
Quote:

SetTriggerOption("%<list>","other_text_colour",utils.split("%<args>"," ")[1])


I'm not really following how this works. Can you paste the whole alias?

- Nick Gammon

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

Posted by Cino   Australia  (17 posts)  Bio
Date Reply #9 on Fri 23 Jun 2006 09:11 AM (UTC)

Amended on Fri 23 Jun 2006 09:13 AM (UTC) by Cino

Message
Alrighty.

First up,
<triggers>
  <trigger
   custom_colour="17"
   enabled="y"
   match="match this"
   name="testtrigger"
   sequence="1"
   other_text_colour="mistyrose"
  >
  </trigger>
</triggers>


/SetTriggerOption("testtrigger","other_text_colour","green") at the command line does not appear to change the trigger.


As for my alias, it may appear somewhat convoluted.. I thought one would be neater, but as it grows it may be best to split or feed into a function. I removed the code from the other else/ifs for clarity, and they work as expected.

<aliases>
  <alias
   match="^name:(?P&lt;cmd&gt;(add|remove|colour|show|createlist|deletelist)) (?P&lt;list&gt;\w+)(| (?P&lt;args&gt;.+))$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="1"
  >
  <send>if "%&lt;cmd&gt;"=="add" then
 -- add name
elseif "%&lt;cmd&gt;"=="remove" then
 -- remove name

elseif "%&lt;cmd&gt;"=="colour" then
 SetTriggerOption("%&lt;list&gt;","other_text_colour",utils.split("%&lt;args&gt;"," ")[1])
 SetTriggerOption("%&lt;list&gt;","other_back_colour",utils.split("%&lt;args&gt;"," ")[2])
 SetVariable("%&lt;list&gt;",string.gsub(GetVariable("%&lt;list&gt;"),"^[#%a%d]+|[#%a%d]+",utils.split("%&lt;args&gt;"," ")[1].."|"..utils.split("%&lt;args&gt;"," ")[2],1))
 Note("Changed colour of: ".."%&lt;list&gt;"..", to "..utils.split("%&lt;args&gt;"," ")[1].." on "..utils.split("%&lt;args&gt;"," ")[2]..".")

elseif "%&lt;cmd&gt;"=="show" then
 -- show names in list
elseif "%&lt;cmd&gt;"=="createlist" then
 -- create variable and trigger
elseif "%&lt;cmd&gt;"=="deletelist" then
 -- delete variable and trigger
end</send>
  </alias>
</aliases>


Using say, name:colour friends yellow #FFFFFF does not modify the trigger, but the confirmation Note is shown.

The variable structure is simply "frontcolour|backcolour|player|anotherplayer|etc" where the name is the list it represents.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #10 on Fri 23 Jun 2006 10:02 PM (UTC)
Message
Quote:

/SetTriggerOption("testtrigger","other_text_colour","green")


It helps in situations like this to print the return code. Many functions return a code to indicate success or failure. Let's try that:


print (SetTriggerOption("testtrigger","other_text_colour","green")) --> 30026


A code of other than zero from this function means failure, so you can see that the colour won't change. You can find the exact meaning a number of ways. One neat way is to use the "check" function supplied in the example Lua script file:


check (SetTriggerOption("testtrigger","other_text_colour","green")) --> New value for option is out of range


Or, you could do this:


/print (error_desc [30026]) -> New value for option is out of range


Now what is out of range about "green"? Let's see what it was before we changed it:


print (GetTriggerOption("test","other_text_colour")) --> 4678655


Aha! It printed a number, thus the colour is an RGB one, not a name. Thus your solution is to do this:


SetTriggerOption("test","other_text_colour", ColourNameToRGB ("green"))


I admit the documentation does not specifically say what sort of colour it is, I will amend 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.


28,448 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.