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?
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?
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.
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?
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.
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 :)
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. :)