mIRC Homepage
Posted By: ots654685 Color loop - 28/02/09 11:11 PM
Was hoping anyone can help me out.

I was trying to modify mirc that when an certain script is called it would reply in different color and maybe just a selection of colors.

for example:
1e time script reply's color is red
2e time color is green
3e time color is yellow
4e time color is red again

any suggestions on how to do that or where to look for more help to figure it out myself?
Posted By: RusselB Re: Color loop - 28/02/09 11:35 PM
In your script, press Ctrl+K then the number for the colour you want, then the text that you want coloured.

You can also put the colour number into a variable (%colour in the folowing example) and then use something like
Code:
msg $chan $+($chr(3),%colour) text
$chr(3) is the equivalent of pressing Ctrl+k in mIRC

Thus a script might look like
Code:
on *:text:Hi*:#:{
  if $me isin $2- {
    var %colour = $r(0,16)
    %colour = $iif(%colour == 16,99,%colour)
    .msg $chan $+($chr(3),%colour) Hi $nick
  }
}

As mIRC has 16 colours in it's colour pallette (numbered 0 to 15), I add an extra number (16) then check to see if the random colour number matches 16, and if it does, I set it to 99, which always returns the system default colour.

Note that some people might not be able to see/read the reply easily, as there's a chance that your reply colour matches their background colour or that it is very close (eg: yellow on white is hard to read for most people)
Posted By: ots654685 Re: Color loop - 28/02/09 11:40 PM
Thanks for the reply but will this loop?

In your example it will pick all colors available but with some modification i can make it to pick only 2 5 8 as color at almost the same way?
Posted By: Horstl Re: Color loop - 01/03/09 01:18 AM
Something like
Code:
alias lcol {

  ; set the colors you want to loop here, separated by space
  var %colors = 7 4 10 3

  $iif((%lcol.current >= $numtok(%colors,32)),set,inc) %lcol.current 1 
  return $chr(3) $+ $base($gettok(%colors,%lcol.current,32),10,10,2)
}
Simply put "$lcol" instead of the control-k<colornumber> in your script. Every time you call "lcol" the color is changed.

Example:
//echo -a $lcol Test
//echo -a $lcol Test
//echo -a $lcol Test

To remove the additional space, use "$lcol $+". Example:
Code:
//say $lcol $+ Hi, $lcol $+ This is a $lcol $+ test!

(you don't need the "//" in your script, they are only needed for tests with the editbox)
Posted By: RusselB Re: Color loop - 01/03/09 01:18 AM
Here's a re-write using just the colours you specified, and having them loop in sequence, rather than being chosen randomly
Code:
on *:text:Hi*:#:{
  if $me isin $2- {
    inc %colour
    %colour = $iif(%colour > 3,1,%colour)
    .msg $chan $+($chr(3),$gettok(2 5 8,%colour,32)) Hi $nick
  }
}

© mIRC Discussion Forums