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
➜ Lua
➜ Need help with a multi line trigger
Need help with a multi line trigger
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Zec121212
(2 posts) Bio
|
Date
| Mon 29 Aug 2011 08:28 PM (UTC) |
Message
| Basically what I am trying to do is this:
I type in WHO HERE and get a prompt that looks like this:
4304h, 1810m, 20420e, 8086w, 72% exdb-(-32 Mana)
who here
You see the following people here:
Hatusk, Jerminyn, Glacial, Derilek
4304h, 1778m, 20420e, 8086w, 72% exdb-(-32 Mana)
Basically what I would like to do is have it trigger on that and send
ENEMY HATUSK
ENEMY JARMINYN
ENEMY GLACIAL
ENEMY DERILEK
I am having issues with the commas and simply getting the trigger to fire at all with two lines.
this is what I have so far, any tips would be greatly appreciated.
<triggers>
<trigger
enabled="y"
expand_variables="y"
lines_to_match="2"
match="You see the following people here:$ ^\w, \w, \w, \w, \w, \w"
multi_line="y"
regexp="y"
sequence="100"
>
<send>sit</send>
</trigger>
</triggers>
| Top |
|
Posted by
| Chyort
USA (58 posts) Bio
|
Date
| Reply #1 on Mon 29 Aug 2011 11:19 PM (UTC) Amended on Mon 29 Aug 2011 11:25 PM (UTC) by Chyort
|
Message
| you need to tell it where the newline is
<triggers>
<trigger
enabled="y"
lines_to_match="2"
match="Relina utters the words\, \'uwwaburukz\'\.$\n^$"
multi_line="y"
regexp="y"
>
<send>tell relina immob missed</send>
</trigger>
</triggers>
one of my simple triggers. matches on relina utters, and then a blank line.
Basically though, you need a \n...
so
match="You see the following people here:$\n^\w, \w, \w, \w, \w, \w"
Anyways, that is what i see :P could well be more :) | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #2 on Tue 30 Aug 2011 06:57 AM (UTC) |
Message
| I assume you don't see the same number of people each time, so you probably just want to grab the whole line and then split it up, like this:
<triggers>
<trigger
enabled="y"
group="My Enemies"
lines_to_match="2"
keep_evaluating="y"
match="^You see the following people here\:\n(.*)\Z"
multi_line="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
for k, v in ipairs (utils.split ("%1", ",")) do
Send ("enemy " .. Trim (v))
end -- for
</send>
</trigger>
</triggers>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Zec121212
(2 posts) Bio
|
Date
| Reply #3 on Wed 31 Aug 2011 01:59 PM (UTC) |
Message
| That worked like a charm, but I don't understand this at all:
for k, v in ipairs (utils.split ("%1", ",")) do
Send ("enemy " .. Trim (v))
end -- for
| Top |
|
Posted by
| Ircria
(24 posts) Bio
|
Date
| Reply #4 on Wed 31 Aug 2011 05:23 PM (UTC) |
Message
|
Zec121212 said:
That worked like a charm, but I don't understand this at all:
for k, v in ipairs (utils.split ("%1", ",")) do
Send ("enemy " .. Trim (v))
end -- for
utils.split creates a table out of a string (parameter one) using the delimiter (parameter two) to decide where to seperate. For example, "a,b,c,d" becomes {"a", "b", "c", "d"}
Assuming you know what ipairs does, so continuing... For each entry in that table, send the line "enemy "..Trim(v), where v is the value in the aforementioned table. Trim() just shaves the whitespace off either end of the string. So with the table above, you'd be sending
enemy a
enemy b
enemy c
enemy d | 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,932 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top