mIRC Homepage
hello again,

i was wondering if there was a way to either strip a certain color from echoing text or replace a specific color with another one?? like per say if someone has white text and you have a white background, have it change to a visable color.. same with black also.. FYI(what i'm doing is echoing text from a channel window into a custom window). so, is this possible??

thanks for any info in advance...
If you don't need to maintain the other colors, you can simply do:

$strip($1-,c)

if you need to maintain the rest, you can do something like:

$replace($1-,00,15,01,14)

Note that this will only work with double digit control codes for 0 and 1. If you try with just 0 or 1, it will replace more than you want. Some people don't use two digit control codes, so this won't always help.
Quote:
Note that this will only work with double digit control codes for 0 and 1. If you try with just 0 or 1, it will replace more than you want. Some people don't use two digit control codes, so this won't always help.


so in otherwords, this picks up on what color codes another user is using? or did you mean the user implimenting this peice of code??...
You are replacing the text in the on text or on input (so it depends which you are triggering it from)... on text is another person, on input is you.

If someone had, let's say, black text and it was made black using Ctrl-K 1 instead of Ctrl-K 01, then the code I listed wouldn't work because the code looks for Ctrl-K 01.

The problem with looking for Ctrl-K 1 is that it would make changes to Ctrl-K 10 and 11 and 12 (etc) as well.

Now, if you really need it to keep all other colors, then we can make a longer script that will change things correctly. Just let me know if you need it.

$strip will remove all colors, so would work just fine if you don't need color.

As a side note when doing scripts, padding colors (making 1 into 01 for example) is a wise thing to do as it prevents errors later.
it's really not a "need" per say to keep the colors but, i'd like to keep in tack the original format as much as possible when echoing to the other window, ya know? so, if ya can(and if it's not too much of a bother) could ya go ahead and post that code..? (i'd like to see how that would be done grin )

thanks in advance Riamus2
Code:
on *:text:*:#yourchannel: {
  var %temptext < $+ $nick $+ > $1-
  if ($chr(3) isin %temptext) {
    set %i 1
    while (%i <= $gettok($1-,0,3)) {
      if ($left($gettok($1-,%i,3),1) == 0) {
        if ($mid($gettok($1-,%i,3),2,1) !isnum) {
          var %temptext $replace($left($gettok(%temptext,%i,3),1),0,15)
        }
        elseif ($mid($gettok($1-,%i,3),2,1) == 0) {
          var %temptext $replace($left($gettok(%temptext,%i,3),2),00,15)
        }
        elseif ($mid($gettok($1-,%i,3),2,1) == 1) {
          var %temptext $replace($left($gettok(%temptext,%i,3),2),01,14)
        }
      }
      elseif ($left($gettok($1-,%i,3),1) ==  1 && $mid($gettok($1-,%i,3),2,1) !isnum) {
          var %temptext $replace($left($gettok(%temptext,%i,3),1),1,14)
      }
      inc %i
    }
  }
  echo @yourcustomwindow %temptext
}


Ok, this should do it for you. I can't test it right now. If it isn't working, let me know what it is doing.

It will replace any Ctrl-K 0 or Ctrl-K 00 (white) with Ctrl-K 15 (light gray).

It will replace any Ctrl-K 1 or Ctrl-K 01 (black) with Ctrl-K 14 (dark gray).

All other colors should be left alone. Let me know if it works.
Think it would have worked if you made the following type change (on each one)
Code:
          var %temptext $replace($left($gettok(%temptext,%i,3),1),0,15)
to
          var %temptext [color:blue]$puttok(%temptext,[/color] $replace($left($gettok(%temptext,%i,3),1),0,15) [color:blue],%i,3)[/color]


But i think you set the bar higher than you needed to for this one.
you can just uses $replacex, just ensure you process the 0N values first, then the 1N, then N

Code:
on ^*:text:*:#channel:   { echo -itlbfmrc normal $chan $+(<,$nick,>) $replacex($1-,00,00 ,01,01 ,02,02 ,03,03 ,04,04 ,05,05 ,06,06 ,07,07 ,08,08 ,09,09 ,10,10 ,11,11 ,12,12 ,13,13 ,14,14 ,15,15 ,0,0 ,1,1 ,2,2 ,3,3 ,4,4 ,5,5 ,6,6 ,7,7 ,8,8 ,9,9 ) | haltdef }
on ^*:action:*:#channel: { echo -itlbfmrc action $chan * $nick       $replacex($1-,00,00 ,01,01 ,02,02 ,03,03 ,04,04 ,05,05 ,06,06 ,07,07 ,08,08 ,09,09 ,10,10 ,11,11 ,12,12 ,13,13 ,14,14 ,15,15 ,0,0 ,1,1 ,2,2 ,3,3 ,4,4 ,5,5 ,6,6 ,7,7 ,8,8 ,9,9 ) | haltdef }


For anyone who might be reading that and going "but there all the same?!?!?!"
Yes they are, but the idea is you replace the one you want to replace with the new color, ie: red to blue is ,04,12 & ,4,12 and/or blue to grey ,12,15
NB: red being blue well not then convert to grey since $replacex well not effect replaced items, 1's replace wont effect 14 say , becuase 14 has already been replaced, even if it was with itself.

and incase that line is hard to understand (i have to admit its not the clearest thing in the world)
Code:
on ^*:text:*:#channel:   { filter.colors normal $1- }
on ^*:action:*:#channel: { filter.colors action $1- }
alias -l filter.colors {
  ;$1 = normal / action
  ;$2 = text
  ;
  ; %cN represents ctrl-kN color codings in text, set desired replacment value for each below.
  ;
  ; **** It is your responsibility to ensure only valid values are used (0 to 15) ****
  ;
  var %c0  =  0
  var %c1  =  1
  var %c2  =  8
  var %c3  =  3
  var %c4  =  4
  var %c5  =  5
  var %c6  =  6
  var %c7  =  7
  var %c8  =  3
  var %c9  =  9
  var %c10 = 10
  var %c11 = 11
  var %c12 = 12
  var %c13 = 13
  var %c14 = 14
  var %c15 = 15
  ;
  ;Do not adjust the remaining values below here.
  ;
  var %c00 = $+(,$right($+(0,%c0),2)))
  var %c01 = $+(,$right($+(0,%c1),2)))
  var %c02 = $+(,$right($+(0,%c2),2)))
  var %c03 = $+(,$right($+(0,%c3),2)))
  var %c04 = $+(,$right($+(0,%c4),2)))
  var %c05 = $+(,$right($+(0,%c5),2)))
  var %c06 = $+(,$right($+(0,%c6),2)))
  var %c07 = $+(,$right($+(0,%c7),2)))
  var %c08 = $+(,$right($+(0,%c8),2)))
  var %c09 = $+(,$right($+(0,%c9),2)))
  var %c0  = $+(,%c0)
  var %c1  = $+(,%c1)
  var %c2  = $+(,%c2)
  var %c3  = $+(,%c3)
  var %c4  = $+(,%c4)
  var %c5  = $+(,%c5)
  var %c6  = $+(,%c6)
  var %c7  = $+(,%c7)
  var %c8  = $+(,%c8)
  var %c9  = $+(,%c9)
  var %c10 = $+(,%c10)
  var %c11 = $+(,%c11)
  var %c12 = $+(,%c12)
  var %c13 = $+(,%c13)
  var %c14 = $+(,%c14)
  var %c15 = $+(,%c15)
  ;
  echo -itlbfmrc $1 $chan $iif($1 == normal,$+(<,$nick,>),* $nick) $replacex($2-,00,%c00 ,01,%c01 ,02,%c02 ,03,%c03 ,04,%c04 ,05,%c05 ,06,%c06 ,07,%c07 ,08,%c08 ,09,%c09 ,10,%c10 ,11,%c11 ,12,%c12 ,13,%c13 ,14,%c14 ,15,%c15 ,0,%c0 ,1,%c1 ,2,%c2 ,3,%c3 ,4,%c4 ,5,%c5 ,6,%c6 ,7,%c7 ,8,%c8 ,9,%c9 )
  haltdef
}


There is of course alot more processing that mirc must do in that but its easier to understand, when it comes to changing a value.
Bah. I feel stupid now. I completely forgot about $replacex working that way. I was thinking it would be nice if $replace would skip what was already done. D'oh! smile
okay,

thanks guys, for your help.. i'll let ya know how it works .. no time atm... thanks again
© mIRC Discussion Forums