Is there a function for checking trigger group exists or not?

Posted by JY.Chang on Tue 13 Dec 2011 04:17 AM — 5 posts, 19,911 views.

Taiwan #0
Q1: The IsTrigger function is for single trigger, but i want to know is there a function for checking trigger group exists or not?

Q2:
Send ("eat bread\ndrink milk")
Send (FixupEscapeSequences("eat bread\ndrink milk"))


both of above got an error message when send to script, i am new in programming, please tell me where the mistake is?

ps.English is not my mother language, so my english is pretty basic, please don't mind.
USA Global Moderator #1
Quote:
Q1: The IsTrigger function is for single trigger, but i want to know is there a function for checking trigger group exists or not?
I don't think there is a function for this, but why do you want it?

Quote:
Q2:

Send ("eat bread\ndrink milk")
Send (FixupEscapeSequences("eat bread\ndrink milk"))


You could just do
Send("eat bread")
Send("drink milk")
Amended on Tue 13 Dec 2011 04:54 AM by Fiendish
Taiwan #2
Quote:
I don't think there is a function for this, but why do you want it?

I make an alias below to enable a trigger group, and i want to do that error message will popup if the trigger group doesn't exist.
<aliases>
  <alias
   match="t+"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>EnableTriggerGroup("%1",true)
Note("Enable Trigger Group " .. "%1")</send>
  </alias>
</aliases>



Quote:

You could just do
Send("eat bread")
Send("drink milk")

Thank you for your answer, but i wonder how can i do that by just one line command?
Amended on Tue 13 Dec 2011 07:21 AM by JY.Chang
Australia Forum Administrator #3
In send-to-script, \n is converted into a newline (before being sent to Lua). So do this:


Send ("eat bread\\ndrink milk")


Or:


Send ([[
eat bread
drink milk
]])





Quote:

I want to know is there a function for checking trigger group exists or not?


Template:function=EnableTriggerGroup
EnableTriggerGroup

The documentation for the EnableTriggerGroup script function is available online. It is also in the MUSHclient help file.



The function returns the number of items in the group. If the group doesn't exist it would return 0.
Taiwan #4
Nick Gammon said:

In send-to-script, \n is converted into a newline (before being sent to Lua). So do this:


Send ("eat bread\\ndrink milk")


Or:


Send ([[
eat bread
drink milk
]])


-----

(function=EnableTriggerGroup)

The function returns the number of items in the group. If the group doesn't exist it would return 0.


Thank you very much, Nick! You really do me a big favour!