mIRC Home    About    Download    Register    News    Help

Print Thread
#214652 11/08/09 03:26 PM
Joined: Jan 2007
Posts: 280
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Hi, I'm looking for a script which replaces your words with an color. Example:

<Name> hi there how are you, I am fine!

So, it needs 3 colors, which it will repeat. (No random, just color1 color2 color3 color1 color2 color3).

If can, it doesn't need to work when I type something with / or ! etc.etc. (Just like always with the "first letter color"-talkers)



Squee whenever a squee squee's. Squee whenever a squee does not squee.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Give this a try:
Code:
; --- color-per-word talker ---
on *:input:*:{
  if ($readini($mircini,text,commandchar) $+ * !iswm $1) && (!$ctrlenter) && ($istok(channel.query.chat,$window($active).type,46)) { 

    ; --- put the numbers of the colors to loop here (zeropad all single-digit color numbers) ---
    var %cols = 04 12 08

    var %num = $numtok(%cols,32)
    msg $active $$regsubex($strip($1-),/(\S+)/g,$+($chr(3),$gettok(%cols,$iif(($calc(\n % %num) == 0),%num,$v1),32),\t))

    haltdef
  }
}


Edit: fixed it to work for more than 9 colors-to-loop; put haltdef for halt

Last edited by Horstl; 11/08/09 04:10 PM.
Joined: Jan 2007
Posts: 280
Fjord artisan
OP Offline
Fjord artisan
Joined: Jan 2007
Posts: 280
Thanks!:)


Squee whenever a squee squee's. Squee whenever a squee does not squee.
Joined: Sep 2009
Posts: 1
N
Mostly harmless
Offline
Mostly harmless
N
Joined: Sep 2009
Posts: 1
Do you know how to make it so that it also counts how many spaces you put?

For the current script:

Code:
; --- color-per-word talker ---
on *:input:*:{
  if ($readini($mircini,text,commandchar) $+ * !iswm $1) && (!$ctrlenter) && ($istok(channel.query.chat,$window($active).type,46)) { 

    ; --- put the numbers of the colors to loop here (zeropad all single-digit color numbers) ---
    var %cols = 04 12 08

    var %num = $numtok(%cols,32)
    msg $active $$regsubex($strip($1-),/(\S+)/g,$+($chr(3),$gettok(%cols,$iif(($calc(\n % %num) == 0),%num,$v1),32),\t))

    haltdef
  }
}


(I will use "_" to represent space.)

If I typed "Hello.______How_are_you?",
It would come out as "Hello._How_are_you?".

I'm making my own talker script and was wondering if anyone knew how to modify it so that it counts all your spaces as well.

Last edited by never_lose; 09/09/09 03:26 AM.
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
I don't, sorry.

The problem is not with preserving leading/trailing/consecutive spaces in the script (a common issue; one can word around it).
It's rather acccessing the original input string: You can access the input text only with the identifier $1-, and the content of $1- is a "space-tokenized" version of the original string (leading/trailing/consecutive spaces are "lost" already).
And while many events contain the original, "full spaced" string in $rawmsg, you cannot use this one in on input either, as there's no inbound message to the client.


Edit: Have a look here for a better explanation and a possible third-party-sollution via "spaces.dll" which contains some "input" function. I don't have any personal experience with this dll, but I'm pretty sure other users on these forums do.

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Try, $count($1-,$chr(32))

Joined: Jul 2006
Posts: 4,162
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,162
Quote:
You can access the input text only with the identifier $1-, and the content of $1- is a "space-tokenized" version of the original string (leading/trailing/consecutive spaces are "lost" already).
So anything on $1- won't work


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard