This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

count characters affected by control codes

Old posts that have not been replied to for several years.
Locked
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

count characters affected by control codes

Post by De Kus »

We know all the scripts that count conrol codes and kicks them at a given amount.
But however, I feel sorry for guys beeing kicked from 2 lines that contain only 5 bold characters and offers post 3 lines the whole line in extrem red and bold, so I came up with the idea it would be more fair, if we would count how many characters are really affected by control codes.

I have been looking throught the forum via search, but couldn't find something like that and haven't seen something like that before. Does anybody know if there is already a script or script part doing this?
I would apprectiate any existing code, if there is none, I would probably create one, but I don't want to invent the wheel twice, you know :D. I only hope the CPU usage will be reasonable @_o.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I don't think there's a script that does the check like that, it's a nice idea though.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Depends also upon the font you are using. Plus I've seen COLORS when used with BOLD they mess up. Or alot of control codes used in tsunami floods usually do too as we know. Don't match individual ones, try certain combinations of all 4-5 of them.

if {[string match "*[boldcode][reversecode]*"]} and {total_codes >= bla}
if {[string match "*[boldcode][underlinecode]*"]} and {total_codes >= bla}
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

the font that someone is using will not affect how many characters the control will affect.
ex.: "Nick\002:\002 hello"
will have 1 affected character which is ":" no matter what font you use.
ex.: "\002\0034stop it !\003\002"
will have 14 affected characters, twice "stopit!", no matter what font you use.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Then my guess is to use string index for $text, incr the index by 1 everytime you pass the foreach loop, and check the control character in each index, and if match check the control character in following the text after the control character. Set a list of characters you wouldn't want to allow.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

I already had an idea about splitten the text in each control char like:
set bold [split $text \002]
set color [split $text \003]
in bold each element with index 1,3,5, etc will contain affected chars (after stripping other control codes) for colors, i would do a ^[0-9]{1,2},?[0-9]{0,2} regsub to delete the color code and the result of the regsub tells me, if it was a start or close tag. But however, it would be easier to start with some known working code.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

So, something I wrote together in a few minutes, haven't tested it yet. Do you think thats a good start?
If this works it might be even CPU friendly enough for a bind to pubm.
Last edited by De Kus on Mon Apr 18, 2005 2:13 pm, edited 1 time in total.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

I was bored, I know :D.
I will debug the code later (so assume it has error and might even not run at all ^^)
Any suggestions regarding the features?

PS: first debugging done.

PPS: code moved to http://forum.egghelp.org/viewtopic.php?t=9434
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Locked