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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Amfitrion
Wanderer


Joined: 29 Sep 2001
Posts: 75
Location: Israel

PostPosted: Tue Jul 08, 2003 8:07 pm   

Capturing colors
 
How do I capture a word WITH the color?

Example:
This text is colored.

How do I capture "text" with the color?

Ultimately, I want to put it in the status window.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jul 09, 2003 2:34 am   
 
This is easily done with an ordinary window, which is designed to display captured text. Just use a trigger and #CAPTURE, the color codes from the MUD are included.
#TR {text} {#CAP color}

The status window isn't designed to display captured text. It's designed to be given a fixed definition, with information updated as the variables in that definition change. You'll probably have to investigate trigger types which pass all received data (ansi, mxp, etc) to the parser, design some complicated parsing to strip out the color codes and determine the colors being used, and then do some creative variable writing to get the appropriate color codes into the variables in a way that won't get ignored by the status window.
Reply with quote
Amfitrion
Wanderer


Joined: 29 Sep 2001
Posts: 75
Location: Israel

PostPosted: Wed Jul 09, 2003 12:32 pm   
 
Maybe I didn't explain myself well. I don't want to #CAP the text to a different window. I want to make a variable that will contain the colored text.
Look at the example I gave in the first post:
#trigger {This (%w) is colored.} {colored = %1}

In this case, I want the word "text" to be in the variable "colored", with colors :)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jul 09, 2003 5:11 pm   
 
Maybe I didn't explain myself well. I know you don't want to #CAP to a different window. Read the second paragraph!

To paraphrase what I already said:
You'll have to write a trigger which detects the color. The trigger will then have to place the color information in the variable in such a way that the status window will display that color. It probably won't be easy to do.
Reply with quote
Siddha
Beginner


Joined: 07 Jul 2003
Posts: 15

PostPosted: Wed Jul 09, 2003 5:15 pm   
 
depends where do u want this var to be displayed...
in window:
#cw => will color just ur word
#co => will color whole line

in status window:
%ansi(red)Ur var: @var => red color of variable

etc/
look in help, search for word color
Reply with quote
Amfitrion
Wanderer


Joined: 29 Sep 2001
Posts: 75
Location: Israel

PostPosted: Wed Jul 09, 2003 9:18 pm   
 
Heh, I think I failed to explain myself again.

I receive a text from the mud, in which one word is colored.
I want to display that word, with the color it has in the main window, in the status window.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Jul 09, 2003 11:00 pm   
 
Yes, we understood you. LightBulb said what you need to do. The problem is that although what you want to do is simple, the solution is not.

First, triggers, by default, ignore all color codes on the etxt received by the MUD. If you want a trigger to take color into consideration, then you have to check the ANSI Trigger option for that trigger. Now comes the problem. With this option enabled, zMUD expects to see in the pattern of the trigger the exact ANSI codes that it should match from the MUD. Since you don't know what color the word is, you would have to use * to allow for the color code of the word plus the word itself. However, the bright ANSI codes may also contain a ;. Since * doesn't match this, you would have to use %*, which now introduces a security problem. %* is a risky pattern matching operator unless it is used in a very specific way.

Assuming that all of this is done correctly, then you would end up with a variable that hopefully contains the color code plus the word you want. After that, this variable can be sent directly to the status window and it should display with the color. Here is an example trigger for the example text you provided (you didn't give much more to go on, so it would probably not work right away):
#TRIGGER {This &%*{word} is colored.} {} "" {color}

and the definition for the status window:
#STW {The captured word was: %expand(@word, 1)}

However, if the is any other color change in one of the other words to be matched, the trigger won't even fire. Also, the @word variable must never be used without the %expand in exactly the same way it was used above, plus even though the trigger also saves into %1 what was stored into the variable, %1 must never be used for that trigger since it poses a security risk.

As you can see, what you want to do is simple, but the solution really is not.
Reply with quote
Amfitrion
Wanderer


Joined: 29 Sep 2001
Posts: 75
Location: Israel

PostPosted: Wed Jul 09, 2003 11:25 pm   
 
I tried it, it didn't work. Here is the trigger I tried:

#TRIGGER {^You sense that the alignment of (*) is &%*{tempalign}~.} {#stw {%expand( @tempalign, 1)}} "" {color}

It doesn't fire when it is ansi trigger, only when it is not ansi.

The line it should trigger on is:
You sense that the alignment of anyname is few words here.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jul 10, 2003 12:22 pm   
 
Yes, that's what I'm saying. If the line contains any color codes that will not be captured by the %*, then zMUD expects to see them in the pattern. Otherwise, the trigger will not match.

I do not know what you MUD output looks like, so I couldn't know why it doesn't fire.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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