Separating my MUD prompt

Posted by Poromenos on Sun 12 Aug 2001 10:06 AM — 8 posts, 21,065 views.

Greece #0
I'm STILL trying to color my prompt. Can I make a trigger so that MUSHClient colors the first <*> it sees? Currently, if it sees "<Prompt> He says: Text <text>" it colors from the start to the last bracket. How can i get it to
match on the prompt only?
Australia Forum Administrator #1
Make the trigger a regular expression, then it only colours the exact thing it matches on.

However regular expressions have slightly different rules, if you are matching on <*> you might to write it as:



\<.*\>
Greece #2
Even so, MUSHClient matches on the last closing bracket it sees, not on the first. E.G. "colour <this> not <that>" colours from <this> to <that>, not just <this>. is there any way to get it co match the first closing bracket?
Australia Forum Administrator #3
Ah, OK. You need to add a question mark, like this:


\<.*?\>


This is discussed in the file RegularExpressions.txt that ships with MUSHclient:



By default, the quantifiers  are  "greedy",  that  is,  they
match  as much as possible (up to the maximum number of per-
mitted times), without causing the rest of  the  pattern  to
fail. The classic example of where this gives problems is in
trying to match comments in C programs. These appear between
the  sequences /* and */ and within the sequence, individual
* and / characters may appear. An attempt to  match  C  com-
ments by applying the pattern

 /\*.*\*/

to the string

 /* first command */  not comment  /* second comment */

fails, because it matches  the  entire  string  due  to  the
greediness of the .*  item.

However, if a quantifier is followed  by  a  question  mark,
then it ceases to be greedy, and instead matches the minimum
number of times possible, so the pattern

 /\*.*?\*/

does the right thing with the C comments. The meaning of the
various  quantifiers is not otherwise changed, just the pre-
ferred number of matches.
Greece #4
I tried to separate my prompt (mentioned here as <Prompt> because it is enclosed in brackets) from the text coming after it. For example, I want "<Prompt>Text after prompt" in two lines. I used matching on "^(\<.*?\>)(.*)$" and then outputting %1\n%2 but I use MUSHClient's prompt coloring, and now the prompt colors are all messed up (the prompt is either colored white or with the normal text color). Is there any way that I can color it? Use triggers that match on output perhaps?
Australia Forum Administrator #5
This is a bit trickier - to keep the existing colours you cannot change the text. Once you change the text (eg. by adding a newline) you have to echo it to the world, which will discard the colours. However there is a way to change some colours, even if they are not the absolute original ones in the line.

You can do this with a bit of scripting, and changing "note" colours in the script. Something like this:


Match on: ^(\<.*?\>)(.*)$


(Which you have done). This will give you two wildcards, the first being the prompt and the second being the rest of the line.

Now change some more fields in the trigger:


Omit from output: checked
Label: prompttrigger
Script: OnPrompt



The script needs to change the note colours and then do a "world.note" for each line. Something like this:


sub OnPrompt (strName, strLine, aryWildcards)
world.notecolourfore = vbRed ' set prompt colour
world.note aryWildcards (1) ' show prompt
world.notecolourfore = vbGreen ' set text colour
world.note aryWildcards (2) ' show text
end sub


You could choose any colour you like of course, and MUSHclient now has a "colour picker" built in, which lets you choose a colour visually.

This method lets you colour the prompt and the line different colours, but you are discarding the original colours from the MUD. At present that is unavoidable, if you want to change the text itself.
Amended on Tue 14 Aug 2001 02:41 AM by Nick Gammon
Greece #6
Wouldn't it be better though to make MUSHClient support ANSI codes in triggers (kind of like mIRC)? For example, instead of choosing the colour I would like to make the line, I could write:

say ^K4 This is a red line
say ^K10 This is a black line

^K<number> being the ansi color character. I think that would make many lives easier :)
Australia Forum Administrator #7
I think that the whole colour handling in MUSHclient could be enhanced a bit, for advanced users.

Right now it handles incoming ANSI colours (all 16 of them), plus MXP colours which can be any one of 17,777,216 colours (256 red X 256 green X 256 blue).

You can also display any of those RGB colours yourself using scripts, as I suggested earlier, however it is admittedly a bit tedious to do, compared to what you are suggesting.

Look forward to enhanced colour management in the next major version. :)