Need help with a multi line trigger

Posted by Zec121212 on Mon 29 Aug 2011 08:28 PM — 5 posts, 20,765 views.

#0
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>
USA #1
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 :)
Amended on Mon 29 Aug 2011 11:25 PM by Chyort
Australia Forum Administrator #2
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>

#3
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


#4
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