Help - Search - Members - Calendar
Full Version: Regular Expression And Coloring Issue
Achaea's Forums > Off-Topic > Tech Support > Client Help
Byrnison
So, I have a trigger to capture information from the prompt and I want to be able to color the flags at the end of the prompt. (the [cexkdb@]) My client is ZMUD and I am using a regular expression that goes like this...

^(\d+)h,\s+(\d+)m,\s+(\d+)e,\s+(\d+)w\s+([cexkdb@]*)

So, I want to be able to color each of the prompt flags something different. The "e" will be blue, the "x" will be green...and so on...

I have searched through the help files and the internet and I just can't seem to get it to work, I assume it has something to do with #PCOL, but I can't figure out exactly how to code it.

Thanks for your help!
Dusty
#PCOL blue %5

?
Trevize
Use %x5 not %5 when using #PCOL.

However, since you want to match only part of %5 you need to understand more about how #PCOL works.

It takes three arguments. The color, the start, and end. %x1-99 returns the start and end positions for you, but you can't use them. So you need to figure out a way to get the start and end of where you want coloured another way.

I tried doing that in zMUD using the pattern you gave, this is what I came up with. I basically got the length of the prompt before the flags start by taking the whole match length, removing the length of the flags, and removing two more. Then for each flag I made the start and end position of the colouring the same - the length of the prompt plus the position of the character. Here you go:

promptlen = %eval(%len("%0")-%len("%5")-2)
#pcol blue %eval(@promptlen+%pos("e","%5")) %eval(@promptlen+%pos("e","%5"))
#pcol green %eval(@promptlen+%pos("x","%5")) %eval(@promptlen+%pos("x","%5"))
Dusty
Sorry about that!
Byrnison
Awesome, works perfectly.

Thank you Trevize!
Nitro
This is how keep track of my balance/equi easily. I have 2 buttons on the bottom, below my command bar which are linked to the variables @balance and @equilibrium. When @balance=0 they are pressed into the down state and the color changes from green to red. Same with equilibrium.

I have similar things for focus/plant/salve/health+mana balance.
Pernicios
QUOTE (Nitro @ Feb 13 2009, 07:14 AM) *
This is how keep track of my balance/equi easily. I have 2 buttons on the bottom, below my command bar which are linked to the variables @balance and @equilibrium. When @balance=0 they are pressed into the down state and the color changes from green to red. Same with equilibrium.

I have similar things for focus/plant/salve/health+mana balance.


Status windows/bars seem to be a little cleaner, at least on cmud.... but I used to do the buttons thing too. Now I color the end of my prompt (similar to this threads idea) but the entire cexkdb is a lime color when I have bal/eq, blue when off balance, yellow off eq and red when off both.....
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.