Register forum user name Search FAQ

Gammon Forum

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 ➜ Jscript ➜ Multiple triggers on same line..

Multiple triggers on same line..

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Naz   (4 posts)  Bio
Date Thu 10 May 2001 08:09 PM (UTC)
Message
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

Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Fri 11 May 2001 02:19 AM (UTC)
Message
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?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Naz   (4 posts)  Bio
Date Reply #2 on Fri 11 May 2001 08:08 PM (UTC)
Message
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?
Top

Posted by Naz   (4 posts)  Bio
Date Reply #3 on Fri 11 May 2001 08:31 PM (UTC)
Message
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
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #4 on Fri 11 May 2001 08:44 PM (UTC)
Message
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.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Naz   (4 posts)  Bio
Date Reply #5 on Fri 11 May 2001 08:56 PM (UTC)
Message
Ok.

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

Thanks for your help.

// Naz

Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #6 on Sat 28 Sep 2002 11:37 AM (UTC)
Message
Are there any plans in the works for color escape codes in later versions? or should we not hold our breath?

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #7 on Sat 28 Sep 2002 07:56 PM (UTC)

Amended on Sun 29 Sep 2002 12:09 AM (UTC) by Nick Gammon

Message
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.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
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.


26,992 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.