MUSH Client

by Unknown

Back to Mechanic's Corner.

Unknown2005-11-21 20:50:52
Alright, this is what I want to do. Once hex sense is activated, I want to be able to say Who triggered my hexes, and where they are.

I am able to say who triggered my hexes alright, for example:

Kharvik arrives from the east.
Slithering in from the east, a taint wyrm pollutes the air.
Glowing glyphs in the air flare and explode in Kharvik's face.
You sense Kharvik has activated one of your hexes at centre of the
Necropolis.say Kharvik hit my hexes!

2306h, 3095m, 2660e, 10p ex-
You say, "Kharvik hit my hexes!"

And that was done using this:
Trigger: You sense (.*?) has activated
Send: say %1 hit my hexes!

Ok, this is what happened when I was trying to say who triggered and where, this was done using three variables and using the multi-line fuction:

Caighan arrives from the northwest.
Glowing glyphs in the air flare and explode in Caighan's face.
You sense Caighan has activated one of your hexes at quiet study in the say
Caighan hit my hexes at
Necropolis.say Caighan hit my hexes at
2306h, 3345m, 2660e, 10p ex-say Caighan hit my hexes at
You say, "Caighan hit my hexes at."
2306h, 3345m, 2660e, 10p ex-
You must wait a short while to use a say-like command again.
2306h, 3345m, 2660e, 10p ex-
You must wait a short while to use a say-like command again.
2306h, 3345m, 2660e, 10p ex-
mutter
You mutter discontentedly.

As you can see, something is fishy. Can someone help me put together the proper way of doing this? Any help would be greatly appreciated.


blush.gif
Unknown2005-11-21 20:58:53
Bah, MUSHClient. doh.gif
Terenas2005-11-21 21:01:55
Trigger your say after your prompt, so it won't interfere with your trigger catching.
Ethelon2005-11-21 21:29:35
here ya go...

CODE

    enabled="y"
  lines_to_match="2"
  match="You sense (.*?) has activated one of your hexes at (.*?)\\n(.*?)\\."
  multi_line="y"
  regexp="y"
  sequence="100"
 >
 say %1 hit my hex at %2 %3!
 



erase all your other triggers you made for it already
Unknown2005-11-22 05:02:57
QUOTE(Ethelon @ Nov 21 2005, 02:29 PM)
here ya go...

CODE

    enabled="y"
  lines_to_match="2"
  match="You sense (.*?) has activated one of your hexes at (.*?)\\n(.*?)\\."
  multi_line="y"
  regexp="y"
  sequence="100"
 >
 say %1 hit my hex at %2 %3!
 



erase all your other triggers you made for it already
226344



where am I supposed to put that? O_o
Unknown2005-11-22 07:17:32
Copy the trigger here then go to the Triggers dialogue in Mushclient and click the Paste button there.
Unknown2005-11-22 16:37:47
um... if im not mistaken that looks a little like code, not something you can just paste in the ' triggers dialogue '

im lost -.- ....

EDIT: I forgot mush has that wierd paste button, used it. Its not working Ethelon, nothings working. Hrm, somethings fishy yet again...
Suhnaye2005-11-22 18:49:42
Hrm... I can see a way of doing it by using variables... I've not run into that problem yet, but it is a bit of an issue... I'm not really sure how to use the multi-line match or how it works... Anyone able to explain it better than the help file in MUSH client?
Unknown2005-11-22 23:51:53
Got it all figured out. Thanks Folks.
Unknown2005-11-24 05:42:48
QUOTE(Suhnaye @ Nov 22 2005, 06:49 PM)
Hrm... I can see a way of doing it by using variables... I've not run into that problem yet, but it is a bit of an issue... I'm not really sure how to use the multi-line match or how it works... Anyone able to explain it better than the help file in MUSH client?
226672



It's simple really. "Plain" triggers are matched on every line of incoming text - text comes in "packets", which may contain many lines delimited by a newline character, just one line, or even less than one line, depending on your luck. So when a packet comes in, the client extracts the text, breaks it up into lines and matches triggers one by one on each line.

Multiline triggers can't work like that, because a packet might contain a partial line, the continuation of which arrives in the next packet. So Mushclient keeps a history of the last 1000 (I think) lines in one huge "pseudo-packet". Every time it encounters a newline in the arriving packet it matches each multiline trigger against so many lines at the _end_ of that pseudo-packet of stored lines. This is why you need to tell it how many lines the trigger must match - so it knows what chunk of the output history to use in the match. Though you can set the number of lines to match to pretty much anything you like, as long as it doesn't exceed the maximum number of stored lines.

Because it works like that, Mushclient can't omit the match of a multiline trigger from output (because most of it has probably been displayed a while ago and omitting it at the time of matching would cause nasty visual effects), or change the colours on any of the matched lines (because some or all of them may have been already styled by "plain" triggers before). So when you need to change the representation of a multiline chunk of text you have to use several "plain" triggers that enable/disable each other as they match.

Using multiline triggers is basically the same deal as with "plain" ones - you just need to check the multiline option for the trigger, set the maximum number of lines to match, and remember that you can only use a regular expression in a multiline trigger. The only regexp character that is special to multiline triggers really is "\\n", which denotes a newline, and that's what you separate the lines in the expression with. You can also match just one line with a multiline trigger too. For example if you are unsure whether the text you want to match will be split between two lines or not, you can make the \\n optional:

^A quick brown fox\\n? jumped over a low fence\\.$

Should match both:

CODE

A quick brown fox
jumped over a low fence.


and

CODE

A quick brown fox jumped over a low fence.