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
tkl1129
Beginner


Joined: 04 Jan 2010
Posts: 11

PostPosted: Sun Jan 10, 2010 4:07 pm   

ANSI Color trigger
 
Hi all,

I'm a Chinese Mud player at Hong Kong, since the Unicode support of zmud & cmud was not release yet, so I'm only using zmud 4.62 only....but the questions below, I don't mind to answer as other version, just in zScript is okay, thanks.

I want to make a trigger that can capture the ANSI color code from a pattern, the pattern like this.

OOOOOOOOOOOOOOOOOOOOOOOOOOOO
OOOOOOOOOOOOOOOOOOOOOOOOOOOO
OOOOOOOOOOOOOOOOOOOOOOOOOOOO
OOOOOOOOOOOOOOOOOOOOOOOOOOOO
OOOOOOOOOOOOOOOOOOOOOOOOOOOO

all are the same symbol, but actually some of them are not in same color, finally this will become a graphic number.
Let @ be a red color of O
and O be a black color of O

the out look is

OO@@@OO@OO@@@OO@@@OOOOOOOOOO
OOOO@OO@OO@O@OOOO@OOOOOOOOOO
OO@@@OO@OO@@@OO@@@OOOOOOOOOO
OOOO@OO@OO@O@OO@OOOOOOOOOOOO
OO@@@OO@OO@@@OO@@@OOOOOOOOOO

This is 3182....

As I want to make a trigger to reconize them, but the 1st step is capture the O in different color first, do you guys have any ideas ?
Many thanks for all
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun Jan 10, 2010 8:00 pm   
 
The problem is that you would need to create multi-lined triggers for every possible number... Or.

Something similar to.

OO%e[12m(*)OO%e[0m(*)O

Then work out from there how many Os you had captured in your matrix. Have fun.

I do not remember if your version of Zmud let you highlight a line and paste it directly into an ANSI trigger.

If not then you can use %e[<number here>m as the beginning of your color and %e[<usually 0 here>m and the end of a color.

Good Luck.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
tkl1129
Beginner


Joined: 04 Jan 2010
Posts: 11

PostPosted: Mon Jan 11, 2010 4:31 am   
 
Thanks for fast reply, I tried your method today, but got another problem

1. it can be hightlight and plase with the ANSI trigger pattern directly, but the pattern was not match
because of the [ symbol..

I try to do testing with only type in #say %ansi(red)Hello
the copied pattern was %e[31mHello%e[0m, and press the "test pattern" was not matched. because the color is random , so I try to set
%e(%*)Hello%(%*), the pattern was matched, and try #show %1 & %2
the %1 cannot capture anyting
the %2 only capture the M
so this maybe not enough for me to make a trigger to reconize the color with word.
I think the failure or capture the string to variables is because of the symbol "["

it this problem got fixed, I think everything is easy to manage
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Jan 11, 2010 6:55 am   
 
[] is a wildcard construct that denotes a range pattern. If you want to use them literally, such as in the case of an ansi code, you need to escape them with the tilde (~) in zscript or with the backslash (\) in regex.

Also, I would not use %*, ever. In this specific case, you can more accurately match the ansi code so there's no reason to use greedier wildcards:

(%e~[[%d;]m)
_________________
EDIT: I didn't like my old signature
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Mon Jan 11, 2010 1:06 pm   
 
Interesting thing this mud is doing. What exactly do they do with these numbers?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Jan 11, 2010 1:57 pm   
 
Dumas, it looks to me like this is anti-bot code, requiring the user to input the number represented by the colored spots.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Jan 11, 2010 7:52 pm   
 
essentially it's ASCII captcha.
_________________
EDIT: I didn't like my old signature
Reply with quote
tkl1129
Beginner


Joined: 04 Jan 2010
Posts: 11

PostPosted: Tue Jan 12, 2010 1:42 pm   
 
exactly, anti-bot code.

Now seems no problem for capture the pattern, thanks, the next step should be figure out the reconization of the "numbers"
XD
Reply with quote
kendric
Newbie


Joined: 09 Dec 2009
Posts: 8

PostPosted: Thu Jan 14, 2010 10:19 pm   
 
You could code this such that you build an array of 0s and 1s based on each line that is comming in. Then you have some table that has all the things you want to match against. Would be a lot of work but adding new words would be less work, you just would set the values at the x,y co-ordinates of the new thing you want to catch to 1.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Jan 15, 2010 3:49 am   
 
First you can probably assume that there are always two 0s between every number.
And that every set of numbers begins with 00.
So you should capture everything between sets of 00 without color but keep track of which ones have color perhaps by changing them to ones.

You could use a database record for each number for example.

firstnum is the variable name.

key1 is 1
key2 is 1
key3 is 1
key4 is 1
key5 is 1

The number 1 is a special case. If your pattern for the top line contains 00100, then
your current number is 1.

key1 is 111
key2 is 101
key3 is 111
key4 is 101
key5 is 111

#if ((%db(firstnum,key1)=111) and (%db(firstnum,key2)=101) and (%db(firstnum,key3)=111) and (%db(firstnum,key4)=101) and (%db(firstnum,key5)=111)) {number1=8}

At any rate I hope you get the idea.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
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