Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Apocalyptic
Beginner


Joined: 27 Aug 2007
Posts: 25

PostPosted: Thu Oct 25, 2007 7:08 pm   

Highlighting names
 
How do I highlight names so I can immediately distinguish them from other text in CMUD? Is there an easy way to do this and if so, how?
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Thu Oct 25, 2007 7:21 pm   
 
#TRIGGER {@names} {#CW yellow}

Where names is a string list (names = Zugg|Guinn|Apocalyptic)
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Oct 25, 2007 10:37 pm   
 
I'm pretty sure you need to use

#trig {{@names}} {#cw yellow}

because {one|two} is the syntax for multiple patterns, and @names, if it's a stringlist, expands to one|two. Also, if you have "Guy" on your list and someone's name is "Guybrush", it'll highlight part of their name. To avoid that, you can use %q as well, to get:

#trig {%q{@names}%q} {#cw yellow}

More info on %q is in the comments of this help article.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Apocalyptic
Beginner


Joined: 27 Aug 2007
Posts: 25

PostPosted: Thu Oct 25, 2007 11:17 pm   
 
How and where do I make a string list?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Oct 25, 2007 11:30 pm   
 
#var names ""
#additem names whatever
#additem names whatever2

Repeat #additem as many times as you like.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 26, 2007 1:55 am   
 
You can also usually get away with a direct assignment of a list like this:

names = {Zugg|Guinn|Apocalyptic}

works fine to initialize a list unless you need to have the "|" or quote characters in one of the items. If you need that, then you need to use the #ADDITEM command as Fang mentioned.

Or, open up the Settings Editor, select New/Variable, then select StringList from the "Type" dropdown box in the advanced properties at the bottom of the screen (click the "More" button if the properties are not visible). This will display a string list editor that allows you to easy enter your string list interactively, or edit an existing string list variable.
Reply with quote
Apocalyptic
Beginner


Joined: 27 Aug 2007
Posts: 25

PostPosted: Sat Oct 27, 2007 1:51 am   
 
Do I enter several names in the first row, or do I enter one name per row? How do I choose what colors I highlight them with? How do I type in a command or hit a key to bring up which of them is online and which are not?
Reply with quote
Apocalyptic
Beginner


Joined: 27 Aug 2007
Posts: 25

PostPosted: Sat Oct 27, 2007 2:06 am   
 
Fang Xianfu wrote:
#var names ""
#additem names whatever
#additem names whatever2

Repeat #additem as many times as you like.


So I can use additem to keep adding names later on as I see fit? Must I add the names one at a time like...

#additem names Kilflin
#additem names Max
#additem names Jake
#additem names Jezabel

Is that how it goes? Or can we add several at once? Just trying to figure out how this works. How do I choose the color and ensure that their name will display in that color everyime they enter or leave the room, etc.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Oct 27, 2007 2:53 am   
 
If you get some kind of list output separated by spaces, you could use

#forall %replace(%1," ","|") {#additem names %i}

to add them quickly. You choose the colour by changing the word "yellow" in the trigger above. It can be any websafe colour name, or a hex sequence "#RRGGBB" (the quotes are required).

In the Package Editor, you add one name per row. Each row represents an item in the string list.

I'm not sure what you mean by "How do I type in a command or hit a key to bring up which of them is online and which are not?". All you've asked for is a way of highlighting names (or, indeed, any word) that appears on the screen. That's a totally separate problem, and you'll need to explain it in more detail.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Apocalyptic
Beginner


Joined: 27 Aug 2007
Posts: 25

PostPosted: Sat Oct 27, 2007 3:59 am   
 
How do I fix it when using Alex highlighted it highlights the Alex portion of Alexandrian? How do I make it intelligent enough to differentiate? I did not understand fully the directions to do this earlier.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Oct 27, 2007 4:36 am   
 
The pattern %qAlex%q matches "Alex" but neither "Alexandrian" nor "NotAlex". Just add %q before and after the {@names} part of the pattern to have it only match on those names.

%q matches a word-boundary. This isn't a character - its character width is zero (a normal character's width is 1). It matches the transition point between something that's a word (a-zA-Z0-9) and something that's not a word (a space, a full stop, the start or end of the string, etc). For example, if the parser is checking the string "Alexandrian" against the pattern %qAlex%q, it'll match Alex fine - the parser's position is now on the x. It'll look ahead and see that the next character is an "a". Both the current character, the x, and the next character, the a, are word characters. To match %q, one must be a word character and one must not, and so this doesn't match %q and the match fails.

If that's all a bit complicated, just accept that it works and move on :P
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Apocalyptic
Beginner


Joined: 27 Aug 2007
Posts: 25

PostPosted: Sun Oct 28, 2007 2:02 am   
 
The %q works, but when I use it for another string associate with another trigger it does not work like it does beautifully on the other one. Why is that? How can I fix it?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Oct 28, 2007 3:52 am   
 
Without seeing the pattern you're trying to use it in and a few examples of the text you intend it to match, my answer is unfortunately "with great difficulty".
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sun Oct 28, 2007 10:19 am   
 
Is the other one a regex trigger? If so then %q wouldn't work, I think it might be \b instead
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net