mIRC Home    About    Download    Register    News    Help

Print Thread
#48308 09/09/03 06:14 PM
Joined: Jan 2003
Posts: 13
B
bleah Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2003
Posts: 13
Following up to this thread where color codes higher than 16 are no longer working...

Here's my problem now: I'm using a simple script to change unreadable colors on a certain background color:

on ^*:text:*:#:{ echo $color(text) -tqlbf $chan < $+ $nick $+ > $visible($1-) }
alias visible {
if ($colour(back) == 1) { return $replace($1-,01,14) }
elseif ($colour(back) == 0) { return $replace($1-,00,14) }
}

So, if people are forcing black text on my black background, I'll see 'em, and inversely on white BG.
But if those people use one character color code, like "1text" ?
If I do a $replace($1-,1,14), then when someone says "12text", then my result will be "142text" (displays "2text" in color 14), which is something I didn't want to.

On my original version, I replaced colors 10 to 15 by colors 42 to 47, then replace color 1 by 14, but 'cause of the way $replace works, I'm currently screwed frown

Any ideas on how this could be done?


Show me the steps to somewhere in the sky...
#48309 09/09/03 06:20 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
on ^*:text:*:#:{ 
  echo $color(text) -tqlbf $chan &lt; $+ $nick $+ &gt; $visible($1-) 
  haltdef
}
alias visible {
  if ($colour(back) == 1) { return $replace($1-,01,14) }
  elseif ($colour(back) == 0) { return $replace($1-,00,14) }
}

#48310 09/09/03 06:45 PM
Joined: Jan 2003
Posts: 13
B
bleah Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2003
Posts: 13
Not helpful.
This is the raw event:
<- :nick!ident@host.com PRIVMSG #channel :1This is a test

On my black background (color 1), all I'll see is this:
[14:44] <nick>

... and I want to replace color 1 by color 14 :|


Show me the steps to somewhere in the sky...
#48311 09/09/03 07:17 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
on ^*:text:*:#: {   
  echo $color(text) -tqlbf $chan &lt; $+ $nick $+ &gt; $visible($1-)   
  haltdef
}

alias visible {  
  if ($colour(back) == 1) { return $chr(3) $+ 14 $+ $1- $+ $chr(3)  }   
  elseif ($colour(back) == 0) { return $chr(3) $+ 14 $+ $1- $+ $chr(3) } 
}

This works for me.

#48312 09/09/03 07:55 PM
Joined: Jan 2003
Posts: 13
B
bleah Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2003
Posts: 13
oh god, maybe I'm VERY bad in explanations...

The script you posted just replaces any normal text to color 14.
If I wanted that, I would do menu View, Colors, and change my "Normal Text" there.

The condition to replace text is IF the text contains a control code that is unreadable using a background color.
Try white text on white background
Try black background on black background
Try yellow (8) on white background.

Any other color is acceptable and needs to be displayed normally.


Show me the steps to somewhere in the sky...
#48313 09/09/03 08:40 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Sorry, read it wrong, try:
Code:
on ^*:text:*:#: {   
  echo $color(text) -tqlbf $chan &lt; $+ $nick $+ &gt; $visible($1-)   
  haltdef
}

alias visible {    
  if ($colour(back) == 1) &amp;&amp; ($chr(3) $+ 1 isin $1-) { return $chr(3) $+ 14 $+ $1- $+ $chr(3)  }     
  elseif ($colour(back) == 0) &amp;&amp; ($chr(3) $+ 0 isin $1-) { return $chr(3) $+ 14 $+ $1- $+ $chr(3) } 
}

#48314 09/09/03 09:16 PM
Joined: Jan 2003
Posts: 13
B
bleah Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2003
Posts: 13
Code:
if ($colour(back) == 1) &amp;&amp; ($chr(3) $+ 1 isin $1-) { return $chr(3) $+ 14 $+ $1- $+ $chr(3)  }


This script will catch any control code that starts with a 1
1
10
11
12
13
14
15

frown


Show me the steps to somewhere in the sky...
#48315 09/09/03 09:25 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Try changing isin to iswm.

Last edited by SladeKraven; 09/09/03 09:33 PM.
#48316 09/09/03 10:39 PM
Joined: Jan 2003
Posts: 13
B
bleah Offline OP
Pikka bird
OP Offline
Pikka bird
B
Joined: Jan 2003
Posts: 13
The color codes rule is more complex.

a color code with 1-digit color number (0-9) and alphabetic text (a-z) == colored text
a color code with 2-digits color numbers (00-15) and alphabetic text (a-z) == colored text
a color code with 1-digit color number (0-9) and text which starts with a number (9abc) == 2 digits color number + remaining text (unwished)
a color code with 2-digits color numbers (00-15) and text which starts with a number (9abc) == colored text + the number and text

Keeping in mind that some people can use ^01 or ^1 for black color, or use a color between 10 and 15, the script has to detect if the next character is a letter or a number.
Regex is the solution?


Show me the steps to somewhere in the sky...
#48317 10/09/03 12:23 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Yes, this situation screams for regex. Try this:
Code:
alias visible {
  var %r = /(?&lt;=\x03)(?: $iif($color(back) &lt; 10,0 $ifmatch (?!,\d)| $&amp;
    $ifmatch (?!,?\d),$color(back) (?!,\d)) )/x 
  !.echo -q $regsub($1,%r,$color(normal).dd,%r)
  return %r
}


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard