Multiple triggers on same line..

Posted by Naz on Thu 10 May 2001 08:09 PM — 8 posts, 35,850 views.

#0
I play on MUME (mume.pvv.org 4242)

Its a pk mud where the 'enemies' are surrounded by stars

For example: *an Elf* has arrived from the north.

or: *a noble Elf* has arrived from the north.

Because of the spam many enemies make I made a regexp trigger that triggers on that line looking like this:

\*(.*) Elf\* has arrived from the (.*).$

Now I only highlight elves in green, but I'd also like the
last argument to be parsed. My idea is to gag the oroginal line, and replace it with the follwing(in Green):

*an Elf* has arrived from the <<< WEST <<<

Can that be done? I'd like to use jscript for it if any script is needed.

// Thanks

Australia Forum Administrator #1
The simplest thing would be to have two triggers. One to do the highlighting in green, and the other to match on the direction.

By checking "keep evaluating" on both triggers then MUSHclient will match on one trigger, and then look for another matching trigger on the same line.

Does that solve your problem?
#2
Thanks for your input. It helped me understand what those functions were there for ;-)

I didnt get it to work as I wanted. I did it like this:

Trigger(regexp):
\*(.*) (.*)\*(.*)has arrived from the (west|north|south|east)(.*)

And a script called OnArrive:


function OnArrive (strTriggerName, trig_line, wildcardsVB)
{
  wildcards = VBArray(wildcardsVB).toArray();
  
  race = wildcards[1]
  from = wildcards[3]
  from2 = from
  
  if (race == "Elf") {
    // change color inside * * to green
  } else if (race == "Half-Elf") { // change color inside * * to green
  }  else if (race == "Man") {
    // change color inside * * to blue
  }  else if (race == "Hobbit") {
    // change color inside * * to cyan
  }  else if (race == "Dwarf") {
    // change color inside * * to brown
  }
  

        // For all dirs change color ro bold red
  if (from == "west")
    from2 = "<<< WEST <<<";
  else if (from == "east")
    from2 = ">>> EAST >>>";
  else if (from == "north")
    from2 = "^^^ NORTH ^^^";
  else if (from == "south")
    from2 = "vvv SOUTH vvv";
  else from2 = from;
  
      
  world.note("*" + wildcards[0] + " " + race + "*" + 
             wildcards[2] + "has arrived from the " + 
             from2  + wildcards[4]);

}



So if I get "a man has arrived from the west" it just looks like the triggered line.

And if its "*an Elf* has arrived from the west" that is changed to "*an Elf* has arrived from the <<< WEST <<<"

But.. Now the tricky part. I included if parts for the different races because I like to color *an Elf* green, *a Man* blue and so on, AND the text showing where they went in high red. How can I in Jscript set colors for the different variables/strings? Can it be done?
#3
I added the method world.notecolour(#num) but that colours the whole libe and I only like to color the direction text...

Can I send escape codes to the output window so it show me the colors I want for the word that come after the code?
Thanks.

// Naz
Australia Forum Administrator #4
Not in this version. You aren't the first person to request this. :)

If you do a world.note then you can only choose a colour for the whole line, not individual words.

The trouble is you want to colour the line *and* substitute text.

You can either:

1. Change west to <<< WEST and then colour the whole line in a different colour - the way you have, OR

2. Have two triggers - one to colour Elf in one colour, and another to colour the direction, but this can't then change the text of the line.

#5
Ok.

I think I can live with having the whole line colored :)

Thanks for your help.

// Naz

USA #6
Are there any plans in the works for color escape codes in later versions? or should we not hold our breath?
Canada #7
Since version 3.23, you can now send a multicoloured note line to yourself, which is what Naz wanted to do, above.

See the documentation here: http://www.gammon.com.au/scripts/function.php?name=ColourTell

There is still no method to send ANSI colour codes to the MUD.