Tricky Multi-Line Trigger

Posted by Xavious on Sun 26 Apr 2009 09:20 AM — 2 posts, 13,312 views.

#0
I'm trying to create a crafty automation that will follow targets who flee. I have one trigger that is activated when the client receives "* flees" It then sends the command scan to the mud, which returns the following examples:


______________________________________
[North]
   Nobody there.
[East]
   Riven (Player)
[South]
   biblioclaster
[West]
   Nobody there.
[Up]
   No exits.
[Down]
   No exits.
___________________________________________
[North]
   No exits.
[East]
   No exits.
[South]
   No exits.
[West]
   No exits.
[Up]
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   SpiderDrider (Player)
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
[Down]
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
   exp robot
________________________________________



I'm having trouble getting this to work even if there aren't multiple mobs in the room with the player, however I am dumbfounded as to how I could possibly pull this off WITH multiple mobs in the room.

I tried a multi-line trigger along the lines of:


"[*]\n\s+* (Player)"


However, it is not firing. Any idea or fingers pointed in the right direction greatly appreciated!
Amended on Sun 26 Apr 2009 09:29 PM by Nick Gammon
Australia Forum Administrator #1
Multi-line triggers are really designed for situations where you know the number of lines you expect (eg. a fixed-size status report).

For this sort of situation you probably want the usual 3 triggers approach:

  • One to start matching (eg. on [North] etc.).,

    This turns on the second trigger.
  • One to match each line and considering what to do with it, eg.

    
    exp robot
    SpiderDrider (Player)
    exp robot
    

  • One to match the end of the list (eg. on a prompt). This turns off trigger 2.


So in this case if you were chasing SpiderDrider you use that technique, and when you hit the line "SpiderDrider (Player)" you know he us up from you, because you saved the most recent direction in a variable.