mIRC Home    About    Download    Register    News    Help

Print Thread
#130737 21/09/05 10:46 AM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
Is there a simple way to give the nick you say some color?
i mean not just only at the beginning of the line but nomatter where you say a nick.
there are lots of nickcompleters that give colors to the nick you say but those only do it at the beginning at the line because they use $1.
Anyone any ideas ?

greetzz

#130738 21/09/05 12:54 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Do you want it to color specific nicks, or all nicks? Do you want it to color nicks only if you type them, or when anyone types them? Do you want the nicks colored in the nicklist as well?


Invision Support
#Invision on irc.irchighway.net
#130739 21/09/05 01:19 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Here's a way to color only the nick you start the line with, everywhere it is in the line, but not color nicks others use. Change the color coding and such to anything you like. If you want something else, like I had asked about, just say so and I can change it.

This is meant to be used by typing a nick followed by a colon or other character (Riamus: hello, or Riamus, hello, or something similar).

Code:
on ^*:input:*: {
  haltdef
  if ($left($1,-1) isin $chan || $left($1,-1) == $active) {
    say $replacex($1-,$1,03«09 $+ $left($1,-1) $+ 03»,$left($1,-1),09 $+ $left($1,-1) $+ )
  }
  else say $1-
}


I can't test that right now, but I am pretty sure it works. If not, please let me know and I'll find out why.


Invision Support
#Invision on irc.irchighway.net
#130740 21/09/05 01:53 PM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
oke Riamus2
If you want irt you can get it smile
I want to color all nicks I type.
Not the nicklist because I use nicklust3.dll for that.
I not only want it to color the nick I start the line with but also the nicks I say in the midlle of the line.
And to give you a real hard time I was planning to use it in this input:
Code:
 on &*:INPUT:*: {
  if ($Left($1,1) != /) && (!$Ctrlenter) && ($Active != Status Window) && ($Status == connected) {
    .var %a = $0
    If ($Hget(TempText)) { .hfree TempText }
    .hmake TempText 1
    While (%a) {
      if ($Hget(AcroManager, $Gettok($1-, %a, 32))) { .hadd TempText TempText $Hget(AcroManager, $Gettok($1-, %a, 32)) $Hget(TempText, TempText) }
      Else { .hadd TempText TempText $Gettok($1-, %a, 32) $Hget(TempText, TempText) }
      .dec %a
    }
           msg $active $Hget(TempText, TempText)
    halt         
  }
}
 


Hope you enjoy making itbecause if you make it work I will enjoy using it smile smile wink
If there is anything you want to know ... well let me know.
Btw the input is from my acronym manager.

#130741 21/09/05 03:10 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Lol. Ok, so you want it to color the nicks even if you don't start out the line with the nick. Ok, so here you go:

Code:
alias colornicks {
  [color:blue]; Set variables.[/color]
  var %c = 1,%text = $1-,%i = $gettok(%text,0,32)
  [color:blue]; Loop through each "word."[/color]
  while (%c <= %i) {
    var %nick = $gettok(%text,%c,32)
    [color:blue]; Remove certain symbols from the end of the current word.
    ; This allows you to match "Riamus" and "Riamus." for example.
    ; Add/Remove symbols if necessary.  Note that a nick can't end in these or it won't be colored.[/color]
    while ($right(%nick,1) == : || $right(%nick,1) == - || $right(%nick,1) == $chr(44) || $right(%nick,1) == .) {
      var %nick = $left(%nick,-1)
    }
    [color:blue]; Check if the nick is on the channel or you are in a query or chat with the nick.[/color]
    if (%nick ison $chan || %nick == $active) {
      [color:blue]; Replace the nick with a colored version.
      ; If the nick is the first word, it will put brackets around it.  Otherwise, just color it.[/color]
      if (%c != 1) {
        var %text = $reptok(%text,$gettok(%text,%c,32),$replacex($gettok($1-,%c,32),%nick,09 $+ %nick $+ ))
      }
      else {
        var %text = $reptok(%text,$gettok(%text,%c,32),$replacex($gettok($1-,%c,32),$gettok($1-,%c,32),03«09 $+ %nick $+ 03»))
      }
    }
    inc %c
  }
  [color:blue]; Return text to calling script.[/color]
  return %text
}


Use: $colornicks(text)

So, for using in your current script, just put $colornicks( ) around any output you're giving.

Example:
msg $active $colornicks($Hget(TempText,TempText))

Just as a note... If you have someone with a nick of "a", your output will look weird because all "a" words will be colored. For most situations, this won't happen... just warning you.

Any questions?

This could be done with looping through a channel's nicks and checking for them in the text, but I did it this way and don't feel like rewriting it now. I think this will be faster, anyhow. Especially in larger channels.

Last edited by Riamus2; 21/09/05 03:33 PM.
#130742 21/09/05 07:34 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Oops... forgot a part of $reptok... blush

Use this instead.

Code:
alias colornicks {
  [color:blue]; Set variables.[/color]
  var %c = 1,%text = $1-,%i = $gettok(%text,0,32)
  [color:blue]; Loop through each "word."[/color]
  while (%c <= %i) {
    var %nick = $gettok(%text,%c,32)
    [color:blue]; Remove certain symbols from the end of the current word.
    ; This allows you to match "Riamus" and "Riamus." for example.
    ; Add/Remove symbols if necessary.  Note that a nick can't end in these or it won't be colored.[/color]
    while ($right(%nick,1) == : || $right(%nick,1) == - || $right(%nick,1) == $chr(44) || $right(%nick,1) == . || $right(%nick,1) == ! || $right(%nick,1) == $chr(63)) {
      var %nick = $left(%nick,-1)
    }
    [color:blue]; Check if the nick is on the channel or you are in a query or chat with the nick.[/color]
    if (%nick ison $chan || %nick == $active) {
      [color:blue]; Replace the nick with a colored version.
      ; If the nick is the first word, it will put brackets around it.  Otherwise, just color it.[/color]
      if (%c != 1) {
        var %text = $reptok(%text,$gettok(%text,%c,32),$replacex($gettok($1-,%c,32),%nick,09 $+ %nick $+ ),32)
      }
      else {
        var %text = $reptok(%text,$gettok(%text,%c,32),$replacex($gettok($1-,%c,32),$gettok($1-,%c,32),03«09 $+ %nick $+ 03»),32)
      }
    }
    inc %c
  }
  [color:blue]; Return text to calling script.[/color]
  return %text
}


* I also added ! and ? to the characters that are removed when checking for the nick. This will allow you to colorize nicks even if they have either of those at the end.

Characters removed for checking nicks are:
- , . ! ? :

If you aren't going to use these after a person and you think a nick will have the last character of their nick as one of these characters, just remove it from the IF line.

This is what that removal of symbols is for:

Examples:

Input:
How are you, Riamus?
Output:
How are you, Riamus?


Riamus? isn't going to be in the channel, so we remove the ? from it and then check. The ? will not be colored, but will still appear when we output the text.

Input:
Riamus, how are you?
Output:
«Riamus» how are you?

In this case, the comma is removed to check if the first part is a nick. If it is, then the comma isn't displayed at all (unlike how the ? is still displayed). If the first word is the nick, then any character attached to it (like the comma) will be removed and it will be changed to: «Riamus» instead (with color). Leaving the comma would look weird when doing this replacement. That's part of the IF statement near the end. (A comma after the nick later in the sentence would be displayed normally... this is only removed for the first word).

One final note on that removal... If you do something like:

Darn that Riamus.... I need him!

It will remove all the .'s and then check the nick. The nick will be colored and none of the .'s will be colored (as long as there is a space after the ending period and before the "I").

Last edited by Riamus2; 21/09/05 07:45 PM.
#130743 22/09/05 07:11 AM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
well didn't had time to test the first part yet but the second part seems to work like a charm. grin grin

What i don't understand is the number 32.
In mirc help they have 46 in the example.
What do those numbers mean ? confused confused
Are there more numbers to use on that place ?

Something else.......
Is it possible to color the first letter in the nick with $gettok ?

Last edited by Bullseye; 22/09/05 07:41 AM.
#130744 22/09/05 08:03 AM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Those numbers are the ascii values for the token separators.
32 is the ascii value for the space character, 46 is the ascii value for the period/decimal character.

If you hve a character that you'l like to use, and don't know the ascii value for it, you can get the value by typing //echo -a $asc(<character>)
If you'd like to know what character a particular code is, you can use //echo -a $chr(<ascii code>)

Ascii codes range from 0 - 255

If you want to color the first letter, I'd recommend using $left rther than $gettok

#130745 22/09/05 11:03 AM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
You already used $left.
Can you give me a start on how to begin.
Only a start I want to finish it myself smile

#130746 22/09/05 01:07 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Since you want to finish it, I won't put it into the code, but will just give you an example... If you decide you want me to put it into the code, just let me know. laugh

I'll use $me instead of %nick so that you can just type this in a channel/query and see the output:

//echo -a 04 $+ $left($me,1) $+ 07 $+ $right($me,-1)

$left(text,N)

This will display N letters starting from the left. So, N=1 will make it display the first letter. We set the color for that letter as shown above.

$+ will connect two pieces together so there aren't any spaces added.

$right(text,N)

This works the same was as $left, but from the right instead. By using N=-1, it will display all letters from the right except the "last" letter. Since we are going from the right, the last letter is the first letter of the nick. N=-2 would return all but the first 2 letters of the nick. If you used a negative N for left, it would display all letters except the final letter(s) in the word.

You should be able to edit that line to use %nick and then insert that in the 2 $replacex sections. If you have problems doing it yourself, let me know and I'll give you the code for it.

As a hint, only change what is after 09 in those two lines. Don't change any other %nick information.


Invision Support
#Invision on irc.irchighway.net
#130747 22/09/05 02:44 PM
Joined: Feb 2005
Posts: 344
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
Well i was close .....
I was trying to place the $left in a otherpart of the script like a var.
Guess I was thinking to hard smile
As you showed the aswer is pretty simple.
Thank you.

Greetzz

#130748 22/09/05 02:50 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, the other $left is used just to remove punctuation like I had described. smile


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard