mIRC Home    About    Download    Register    News    Help

Print Thread
#202783 30/07/08 12:40 AM
Joined: Jul 2008
Posts: 3
J
Judy786 Offline OP
Self-satisified door
OP Offline
Self-satisified door
J
Joined: Jul 2008
Posts: 3
Reverse Settings? wanting to change someones black text from a script into white text so that it shows up in my black background. Tried checking and unchecking the strip codes reverse box in options, irc, messages. Didn't work either way. I do not want to strip any of the other colors, so that's not an option.

Something I am missing maybe? Greatly appreciate any help. I did search the forums for my issue but did not find anything other than the strip all color.

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I am working on a script to handle a similar problem. As soon as it's done I will post it (hopefully in the next day to two)

Joined: Aug 2004
Posts: 11
H
Pikka bird
Offline
Pikka bird
H
Joined: Aug 2004
Posts: 11
I've previously had a similar issue with someone writing in a color that made that user's text nearly unreadable to me.

There is a simple and a rather intricate method of resolution.

The simple one is something like that:
Code:
alias h_checkBackgroundColor {
  return $replace($1-,$chr(3) $+ $color(background),$chr(3) $+ $color(normal).dd, $&
  $chr(3) $+ $color(background).dd,$chr(3) $+ $color(normal).dd)
}

This just mulishly replaces everything and that's it.

The more detailed one is something like that:
Code:
alias h_checkBackgroundColor {
  var %h_cBC_Text = $1-
  var %h_cBC_num = 0123456789

  ;$color().dd equals $iif($len($color()) == 1,$chr(48),) $+ $color()
  var %h_cBC_backgroundColor = $color(background).dd
  var %h_cBC_normalColor = $color(normal).dd

  ;$chr(3) is the control character for ctrl+K
  if ($chr(3) isin %h_cBC_Text) {
    var %h_cBC_i = $count(%h_cBC_Text,$chr(3))
    while (%h_cBC_i >= 1) {
      var %h_cBC_pos $calc($pos(%h_cBC_Text,$chr(3),%h_cBC_i) + 1)
      ;checks if color code is followed by a number
      if ($mid(%h_cBC_Text,%h_cBC_pos,1) isin %h_cBC_num) {

        ;the following is to separate that control code from the rest to make it unique,
        ;so that $replace only replaces this single code
        ;accounting for: color + , + 1-digit background (ignored then anyway)
        var %h_cBC_scrap_head = $left(%h_cBC_Text,$calc(%h_cBC_pos - 1))
        var %h_cBC_scrap_tail = $right(%h_cBC_Text,$calc($len(%h_cBC_Text) - (%h_cBC_pos + 3)))
        var %h_cBC_scrap_in = $mid(%h_cBC_Text,%h_cBC_pos,4)

        ;the following is to account for single digit color codes.
        var %h_cBC_scrap_first = $left(%h_cBC_scrap_in,1)
        if ($mid(%h_cBC_scrap_in,2,1) !isin %h_cBC_num) {
          ;$chr(48) is the character also known as "0"
          var %h_cBC_scrap_out = $chr(48) $+ $left(%h_cBC_scrap_in,1) $+ $right(%h_cBC_scrap_in,3)
        }
        else {
          var %h_cBC_scrap_out = %h_cBC_scrap_in
        }

        ;this is to check for existing background color code. else continues if there is none.
        ;$chr(44) is the character also known as ","
        if ($mid(%h_cBC_scrap_out,3,1) == $chr(44)) && ($mid(%h_cBC_scrap_out,4,1) isin %h_cBC_num) { }
        else {

          ;and the following is the actual text color check
          if ($mid(%h_cBC_scrap_out,1,2) == %h_cBC_backgroundColor) {
            set %h_cBC_scrap_out %h_cBC_normalColor $+ $right(%h_cBC_scrap_out,$calc($len(%h_cBC_scrap_out) - 2))
          }
          set %h_cBC_Text %h_cBC_scrap_head $+ %h_cBC_scrap_out $+ %h_cBC_scrap_tail
        }
      }
      dec %h_cBC_i 1
    }
  }
  return %h_cBC_Text
}

In addition to the simpler solution, this one checks for some background color codes and else does about the same thing, just a bit more manually.
One thing it does not is checking for consecutive background color codes like
Code:
3,4Test4,12Test0Test

While 0 may be the default background color, this would result in the third color code being replaced with the default text (aka normal) color despite the fact that it's inherited the background from the second one already. For this example, the simple and the detailed method both result in the same outcome. For a line like
Code:
0,8Test4,12Test3,4Test

their result would differ.

I know those are both pretty crude methods, basically it's just a drawn out $replace, but they should work in whatever "on TEXT/ACTION" event they're used, like
Code:
on ^*:text:*:#:{
  if ($h_checkBackgroundColor($1-) !=== $1-) {
    echo -t $chan < $+ $nick $+ > $h_checkBackgroundColor($1-)
    haltdef
  }
}

Feel free to mess with it.


Link Copied to Clipboard