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
FiendishX
Wanderer


Joined: 19 Nov 2005
Posts: 53

PostPosted: Fri Oct 19, 2007 7:13 am   

#psub and #sub on ansi patterns
 
Given the following block of text:

|||||||||||||||||||||||
|||||||||||*|||||||||||
|||||||||||||||||||||||

if I make an ansi trigger with the pattern:
%e[1;31m(~*)

and the value:
#PSUB "A" %x1

instead of replacing the * with an A, I get:
|||||||||||||||||||||||
|||||||||||*|||||||||||||A||||||||||||||||||||


The same thing also happens if I use #sub instead of #psub.
The ansi trigger pattern was acquired by copying and pasting the red asterisk and then adding the tilde and parentheses.
Why does this happen? And how do I fix it?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Oct 19, 2007 8:03 am   
 
I believe that this is a bug and that it's (or was, anyway) present in CMUD as well. The short answer is that getting to work right is going to be very difficult.

The long answer will probably involve gagging the entire line and then rebuilding it.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
FiendishX
Wanderer


Joined: 19 Nov 2005
Posts: 53

PostPosted: Fri Oct 19, 2007 4:57 pm   
 
Great. Am I allowed to be pissed off at Zugg now for never fixing bugs in zMUD?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Oct 19, 2007 5:52 pm   
 
Well, not sure if this helps, but instead of using the ansi code, change your trigger to be |~*| and sub it with |A|. I'm assuming that the asterisk always follows the pipe, and a pipe follows after.
Reply with quote
FiendishX
Wanderer


Joined: 19 Nov 2005
Posts: 53

PostPosted: Fri Oct 19, 2007 6:19 pm   
 
charneus wrote:
Well, not sure if this helps, but instead of using the ansi code, change your trigger to be |~*| and sub it with |A|. I'm assuming that the asterisk always follows the pipe, and a pipe follows after.
That assumption is wrong. It needs to be based on the ansi code.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri Oct 19, 2007 6:34 pm   
 
Ansi triggers just require special handling.

#TRIGGER {%e[1;31m(~*)} {#PSUB {A} %word(%x1,1) %word(%x1,1)}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
FiendishX
Wanderer


Joined: 19 Nov 2005
Posts: 53

PostPosted: Fri Oct 19, 2007 7:30 pm   
 
Vijilante wrote:
Ansi triggers just require special handling.

#TRIGGER {%e[1;31m(~*)} {#PSUB {A} %word(%x1,1) %word(%x1,1)}

Doesn't work. I get the same as before, only now the A is white.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri Oct 19, 2007 7:37 pm   
 
Sorry misplaced parenthesis in that. Also adding all the option flags this time.
Code:
#TRIGGER {(%e[1;31m~*)} {#PSUB {A} %word(%x1,1) %word(%x1,1)} "" {color}

_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
FiendishX
Wanderer


Joined: 19 Nov 2005
Posts: 53

PostPosted: Sat Oct 20, 2007 3:44 am   
 
Vijilante wrote:
Sorry misplaced parenthesis in that. Also adding all the option flags this time.
Code:
#TRIGGER {(%e[1;31m~*)} {#PSUB {A} %word(%x1,1) %word(%x1,1)} "" {color}

Still no good.
Now it looks like this:
|||||||||||||||||||||||||
|||||||||||
*||||||A||||||
|||||||||||||||||||||||||
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Oct 21, 2007 10:25 pm   
 
FiendishX, I just tested the above code on my system, and it worked. Do you have any other instances of the trigger in your settings? Try deleting them all first and then doing the last one Vijilante suggested.

Charneus
Reply with quote
FiendishX
Wanderer


Joined: 19 Nov 2005
Posts: 53

PostPosted: Wed Apr 02, 2008 5:04 am   
 
I had given up on this a long time ago, but now I'm trying to make it work again.
No, the suggested trigger did not work. No, there were no other triggers on the same pattern.
If the suggested trigger does work for you, then I need to know what special settings you're using.

I think I've managed to make the example work (though it seems like not the right way to do it) by doing the following:

#TRIGGER {(%e[1;31m~*)} {#PSUB {A} %eval( %word( %x1, 1)-7) %eval( %word( %x1, 1)-7)} "" {color}

This seems like a really stupid hack, and it only works for this case and fails when there are other color codes on the line before the pattern.
Still looking for the way to do this that actually works all the time.


Last edited by FiendishX on Mon Apr 14, 2008 7:07 am; edited 1 time in total
Reply with quote
MrCheviot
Novice


Joined: 02 Dec 2007
Posts: 42

PostPosted: Fri Apr 04, 2008 5:50 pm   
 
Code:
#REGEX {^(\033.+m.+)?(\033\[51m(?:.+)?)(\*)((?:.+)?\033.+m.*)?} {#sub {%concat(%1,%2, %ansi(white),"A",%ansi(high,red),%4,%cr)}} "" {color}


I was expecting the [51m to be [1;31m, but when I pasted bold red into trigger w/ ansi mode, it gave me this. Might just be something screwy on my system, but otherwise this was really promising.

It will replace all of the red *'s though, not the first one. Tested w/ the following, all seemed to work. Good luck.

Code:
#show %ansi(blue)xx%ansi(high,red)*%ansi(yellow)yy
#show %ansi(blue)xx%ansi(high,red)123*456%ansi(yellow)yy
#show %ansi(blue)xx%ansi(high,red)~!#*$!~%ansi(yellow)yy
#show %ansi(high,red)123*456%ansi(yellow)yy
#show %ansi(blue)xx%ansi(high,red)123*456
#show %ansi(blue)xx%ansi(high,red)12*34*56%ansi(yellow)yy



-MrC
Reply with quote
FiendishX
Wanderer


Joined: 19 Nov 2005
Posts: 53

PostPosted: Mon Apr 14, 2008 6:54 am   
 
MrCheviot wrote:
Code:
#REGEX {^(\033.+m.+)?(\033\[51m(?:.+)?)(\*)((?:.+)?\033.+m.*)?} {#sub {%concat(%1,%2, %ansi(white),"A",%ansi(high,red),%4,%cr)}} "" {color}


I was expecting the [51m to be [1;31m, but when I pasted bold red into trigger w/ ansi mode, it gave me this. Might just be something screwy on my system, but otherwise this was really promising.

It will replace all of the red *'s though, not the first one. Tested w/ the following, all seemed to work. Good luck.

Code:
#show %ansi(blue)xx%ansi(high,red)*%ansi(yellow)yy
#show %ansi(blue)xx%ansi(high,red)123*456%ansi(yellow)yy
#show %ansi(blue)xx%ansi(high,red)~!#*$!~%ansi(yellow)yy
#show %ansi(high,red)123*456%ansi(yellow)yy
#show %ansi(blue)xx%ansi(high,red)123*456
#show %ansi(blue)xx%ansi(high,red)12*34*56%ansi(yellow)yy



-MrC


Well it's sort of close, but it still doesn't work properly. First it sort of assumes that the line always begins with a color code. That wasn't originally the case, but I've configured zmud to make that happen. So that part is ok. But there's still a problem where if a red * appears on a line preceding non-red *s the non-red ones will also be changed. It also appears to eat blank spaces sometimes, which is bad.

Example:
aasdff*sddsids***
becomes
aasdffAsddsidsAAA
instead of
aasdffAsddsids***

It is getting closer, though. At least this version doesn't screw up the display horribly.
I suspect that the bit between the red color code and the \* needs to be the pattern for "anything but a color code", whatever that is, instead of .+
But I don't know.

Jeez. All of this for something that SHOULD be very simple.
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