mIRC Homepage
Posted By: keptix Individual letter coloring - 30/06/09 11:07 PM
Hey everyone,
I was wondering if anyone could help me with a problem im having? I am trying to create a script that will send what i type coloring each letter differently. I was wanting to display my output in red/white/blue lettering changing every other letter. I've been attempting this for awhile now and can't figure it how. In doing this in on *:INPUT:* however im stumped as to what to do next. Any help would be greatly appreciated. Thanks
Posted By: RusselB Re: Individual letter coloring - 30/06/09 11:51 PM
Untested, but should work per your request.
Please remember, that your actual outgoing message is going to be 3x the length of the message you actually enter, so you will hit the server's message limit 3x sooner than without this code.

Most servers allow at least 256 characters for a message, thus, with this code, you longest message should be kept to 85 characters or less.

Also remember that this code is going to take some time to process the information, thus the longer the message, the longer it will take, and, the longer it will be before people actually see your message.
Code:
on *:input:*:{
  if (/* !iswm $1) {
    var %a = 1, %b = $len($1-), %sent
    while %a <= %b {
      var %colour = $replace($calc(%a % 3),0,4,1,0)
      %sent = $+(%sent,$chr(3),%colour,$mid($1-,%a,1)
      inc %a
    }
    .msg $active %sent
  }
}

Posted By: Wims Re: Individual letter coloring - 01/07/09 01:09 AM
You've missed the blue color in the $replace part smile
Code:
$replace($calc(%a % 3),0,4,1,0,2,12)

Posted By: RusselB Re: Individual letter coloring - 01/07/09 01:56 AM
Well, depends on which blue the OP wanted. 2 is also a shade of blue, so it made no sense to replace 2 with 2, and since the OP stated Red, White and Blue, it made me think of the US flag, in which, imo, the shade of blue used is closer to that of the shade given in 2 than in 12.
Posted By: Wims Re: Individual letter coloring - 01/07/09 02:26 AM
He, didn't think about that, but 2 is just an index, if the index 2 isn't the defaut color for the OP, you (he) still have to change the 2 to the index of a blue color.
Posted By: RusselB Re: Individual letter coloring - 01/07/09 02:49 AM
Point taken, however, that same point stands for any of the colours.
The OP did not indicate that they were working with anything other than the standard colour scheme, so that is what my code was based upon.

It would be impossible to generate a code like was requested without doing a little bit of presuming, such as, the fact that the OP is using the standard colour scheme.

And even your amendment still falls under this potential problem.
Posted By: Horstl Re: Individual letter coloring - 01/07/09 03:10 AM
My suggestion... not for the regsubex' sake! but
- with .msg others will see the colors - you don't
- without a halt, you'll send the text twice (although you see only the one mIRC processes - the custom message was .silenced)
- with single-digit color numbers you can't type digits properly
- the $window().type thingie prevents e.g. messages to custom windows

Code:
on *:input:*:{
  if (/* !iswm $1) && (!$ctrlenter) && ($istok(channel.query.chat,$window($active).type,46)) { 
    msg $active $$regsubex($strip($$1-),/(\S)/g,$+($chr(3),$replacex($calc(\n % 3),0,12,1,04,2,00),\t))
    halt
  }
}

Posted By: Wims Re: Individual letter coloring - 01/07/09 03:24 AM
Looks much better, but if you want to be really perfect, you have to check for $readini($mircini,text,commandchar) and change halt with haltdef.
Also, in on input event, $1 can't be $null, so I think your $regsubex can't too, the only thing that could be $null is the $strip, that the only thing i can't think off that need the $$ here.
Posted By: Horstl Re: Individual letter coloring - 01/07/09 03:46 AM
Was only a suggestion smile The real *fun* would start in conjunction with the desire to "theme" outgoing messages as well, acromanagers, the desire to color /me's or /am*'s too, or a check for chanmodes S/c... shocked
Posted By: RusselB Re: Individual letter coloring - 01/07/09 04:07 AM
If you want that "fun", Horstl, be my guest!!!
Posted By: keptix Re: Individual letter coloring - 01/07/09 05:46 PM
wow thanks for all the replies everyone. I'll give it a shot and let you all know how it comes out. Thanks
© mIRC Discussion Forums