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
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Mon Feb 07, 2005 1:03 am   

trigger and ansi colors
 
well i have a normal trigger tha captures the line
and it works (very well yes) but now i wnat to capture the line with the color in a variable
so i have the line
(color)Life:(color)123/123(Color)HP:(color)123
color = ansi sequence
the normal trigger is easy Life number Hp: number and use the numbers

but now i want is to use the numbers and capture the colors too

i want to do #psub line operations with numbers
in order to see in the same line
(color)Life:(color)123/123(Color)HP:(color)123 -5 -5 -5
-5= some numbers i add with script


the color between lines can be variable so sometimes is yellow other red other blue this is the cause i want to capture the line with colors
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Feb 07, 2005 2:14 am   
 
Will the colors ever change? If not, just #sub the entire line and include the coloring yourself.
_________________
EDIT: I didn't like my old signature
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Mon Feb 07, 2005 7:20 am   
 
yes the colors changes, so sometimes are blue yellow red, it is a random

so i can not do the sub because i want to see that colors, this is the cause i ask for
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Feb 07, 2005 10:36 am   
 
Why play with the colors at all when you don't want to change them. Since this looks like a prompt it may be slightly problematic to always have the number inserted just once. I know it can be done with a more complex regex trigger, but I would have to research the exact usage.

#TR {Life:%d/%dHP:%d()} {#PSUB { -5 -5 -5} %x1} "" {nocr|prompt}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Mon Feb 07, 2005 1:49 pm   
 
i like the colors :D (after i have been playing with them many times)
i only want to add the numbers after the xpression with colors, and vijilante thx for your example but psub doesnt get the colors (this is the first thing i have try :<)

so if the trigger has colors doesnt show them if i do it without ansi colors, if i put the ansi colors tick, the trigger would be very hard no?
(%e%d:%dm)* or something like this, i want the psub but with colors :S
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Tue Feb 08, 2005 9:02 am   
 
Need help?

Is this a prompt with the cursor at the end of it? And does this status line sometimes append itself to the previous line?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Tue Feb 08, 2005 9:29 pm   
 
Quote:
Why play with the colors at all when you don't want to change them.

Vijilante wasn't suggesting you should turn off the colors, he was suggesting that since the colors you want are the colors which are already there, you should just leave them there and you shouldn't need an ANSI trigger. You are creating a problem where none existed.
Code:
#TR {Life:%d/%dHP:(%d)} {#PSUB {%1 -5 -5 -5} %x1} "" {nocr|prompt}
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Tue Feb 08, 2005 11:53 pm   
 
sorry for my explication but it doesn works (for me)
and it isn't a prompt it is like it but not a prompt

for me this is like my problem

say hello
You say: (color)hello
>

">" is my prompt. i want to do is something like #psub but with colors

#tr {(You say: hello)} {#psub {%1 world}}

say hello
You say: hello world>

this i have and dont want
I want:

say hello
You say: (color)hello world
>

the carriage at the end i suppose it is only a %cr in the psub

the thing i ask for is how to put colors

and sorry for the inconvenients Sad
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Wed Feb 09, 2005 8:41 am   
 
This regular expression is good for matching ansi colour sequences
it could be a little more precise but it makes a larger uglier trigger:
(\033[\d*(?:;\d+)*m)

Code:
#CLASS {Test}
#REGEX {(\033\[\d*(?:;\d+)*m)Life:(\033\[\d*(?:;\d+)*m)(\d+)/(\d+)(\033\[\d*(?:;\d+)*m)HP:(\033\[\d*(?:;\d+)*m)(\d+)} {#sub {%1Life:%2%3/%4%5HP:%6%7 -5 -5 -5%cr }} "" {notrig|color}
#CLASS 0



That trigger does the trick for me,using the example string you gave.
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Wed Feb 09, 2005 1:49 pm   
 
not only ugly, i suppose to be very hard for the machine to ask for every line for the trigger

Vijilante have gived me the solution to put () after the line and replace the content of the line with the psub with my last example

#tr {You say: hello()} {#psub {%1 -5 -5 -5} %x1}

say hello
You say: (color)hello -5 -5 -5
>

now i have problems with x1 but making more maths with them (adding number to %x1) i will have i want

Thanks to all
Reply with quote
Pega
Magician


Joined: 08 Jan 2001
Posts: 341
Location: Singapore

PostPosted: Wed Feb 09, 2005 4:57 pm   
 
zMUD v7.05

The truth is #SUB and #PSUB are not ANSI Trigger friendly.

If you want to substitute in a prefix for an ANSI Trigger pattern with #SUB, it is easy because you can match against the ^.
However if you want to append something to the end of the ANSI Trigger pattern in color, using #SUB or #PSUB, it is either very difficult or impossible.

IMHO if you want a clean output in the latter case, the best way is to capture all the variables and reproduce your own output and altogether substituting the entire string.

#SUB and #PSUB work perfectly with non-ANSI Triggers. However, when used in ANSI Triggers #PSUB and #SUB's substitutions are made based on the offset of the text in the trigger string containing ANSI color codes. This is incompatible with the offset of the visible part of the string which it ends up changing. What this means is that using %x1 or #SUB can create undesired results unless they refer to something at the beginning of the trigger pattern or overall string depending on where the unseen ANSI color codes begin.

It may not be too difficult to patch #PSUB for substitutions from the beginning to the middle part of the pattern because you can take the triggered text and use a strip ANSI function to calculate the required offset.

However, appending something into the end of the pattern creates problems. I have no idea what is going on at the end of ANSI Trigger triggered strings. For one, I noticed that the formfeed ASCII character keeps appearing and disappearing on alternate lines when displaying colored text using the #show command.
Reply with quote
jolopez
Novice


Joined: 31 May 2003
Posts: 49

PostPosted: Wed Feb 09, 2005 6:23 pm   
 
yes that is the cause i use #echo with #show it doesn makes the carriage retturn :D
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