mIRC Home    About    Download    Register    News    Help

Print Thread
#5480 08/01/03 04:06 AM
Joined: Dec 2002
Posts: 12
L
loco Offline OP
Pikka bird
OP Offline
Pikka bird
L
Joined: Dec 2002
Posts: 12
i know this was posded befor but i have a black background
and i want to be able to auto change the text thats black to a different color so i can see it.
just cant make it work

#5481 08/01/03 11:14 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
This sample code will use your color for Normal text (text someone else just types) to replace black text.
Code:

on ^*:TEXT:*1*:*:{
  var %i = 1, %1- = $replace($1-,$+(01,$+(,$base([color:red]$color(normal)[/color],10,10,2)))
  while (%i <= $pos(%1-,1,0)) {
    var %pos = $pos(%1-,1,%i)
    if ($mid(%1-,$calc(%pos + 2),1) !isnum) {
      %1- = $+($mid(%1-,1,%pos),$base([color:red]$color(normal)[/color],10,10,2),$mid(%1-,$calc(%pos + 2)))
    }
    else inc %i
  }
  if (%1- != $1-) {
    if (#* iswm $target) {
      if ($gettok($readini($+(",$mircini,"),options,n2),30,44)) $&
        var %nick = $nick($chan,$nick).pnick
      else var %nick = $nick
      echo $color(normal) -bflmrti2 $chan $+(<,,$nick($chan,$nick).color,%nick,,>) %1-
    }
    else {
      echo $color(normal) -bflmrti2 $nick $+(<,,$cnick($nick).color,$nick,,>) %1-
    }
    haltdef
  }
}

If you wish to replace $color(normal) with another of your colors, make sure you either use another index name, like $color(ctcp) for instance, or replace the entire text in red with a number value you wish to use instead, like 00.

The rest of the script should remain unchanged and should follow the rest of your normal mIRC's settings.

Note: This would have probably been MUCH simpler using $regex (if you happen to know RegExp).


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#5482 08/01/03 01:13 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
This method isn't 100% working, for the following reasons:

1) It doesn't take into account mirc's cyclic behaviour with colours. Black is 1, but also 17, 33, 49 etc. So if the black text is created by these numbers, the script won't detect it. Even worse, if the number is 17, the script will replace 1 with $color(normal) giving weird results (fex, if $color(normal) is 5 and the text is 17blah, the script converts it to 057blah).

2) It doesn't take into account the existence of background colouring. It seems logical that the script should not strip black text if this is followed by a background colour, because the sender must have picked a visible combination (and if he didn't, it's his fault :tongue:). The only exception is the background colour 99, which is transparent.

3) The <matchtext> in the on TEXT event catches only 1. Even if you ignore the colour cycling, 01 remains undetected.

Having these in mind, I made an alias that strips black text with the help of -what else?- regular expressions.
Code:
alias stripblack {
  var %r = /(?:1(?=[^\d])|01|17|33|49|65|81|97)(?:(?!,\d)|(?=,99))/g
  !.echo -q $regsub($1,%r, $+ $color(normal).dd,%r)
  return %r
}

on ^*:TEXT:**:*:{
  var %1- = $stripblack($1-)
  if (%1- != $1-) {
    if (#* iswm $target) {
      if ($gettok($readini($+(",$mircini,"),options,n2),30,44)) $&amp;
        var %nick = $nick($chan,$nick).pnick
      else var %nick = $nick
      echo $color(normal) -bflmrti2 $chan $+(&lt;,,$nick($chan,$nick).color,%nick,,&gt;) %1-
    }
    else {
      echo $color(normal) -bflmrti2 $nick $+(&lt;,,$cnick($nick).color,$nick,,&gt;) %1-
    }
    haltdef
  }
}


On a sidenote, $base($color(normal),10,10,2) can be replaced with $color(normal).dd, although the usage of $base here is good for learning purposes (when $color isn't used).

Last edited by qwerty; 08/01/03 01:17 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#5483 08/01/03 01:31 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Heh .. I completely forgot about $color( ).dd.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C

Link Copied to Clipboard