This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
Reynaldo
Halfop
Posts: 54 Joined: Wed May 11, 2005 2:51 am
Post
by Reynaldo » Fri Aug 12, 2005 3:24 am
how to set with random color? from 1-15 colour
Please help.
Dedan
Master
Posts: 260 Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis
Post
by Dedan » Fri Aug 12, 2005 6:38 am
[rand 15] returns a random number between 0 and 14
Code: Select all
set colour [expr [rand 15] + 1]
PRIVMSG $chan :\(\003$colour \002Hi..\002\003\)
i hope this helps
I once was an intelligent young man, now i am old and i can not remember who i was.
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Fri Aug 12, 2005 6:53 am
returns a number in this range [0,15].
metroid
Owner
Posts: 771 Joined: Wed Jun 16, 2004 2:46 am
Post
by metroid » Fri Aug 12, 2005 12:16 pm
0 being nothing is probably why he adds 1
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Fri Aug 12, 2005 1:33 pm
Actually 0 is for white, so I thought he might wanna use it.
Alchera
Revered One
Posts: 3344 Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:
Post
by Alchera » Fri Aug 12, 2005 6:15 pm
MeTroiD wrote: 0 being nothing is probably why he adds 1
There are actually 16 colours, not 15!
Add [SOLVED] to the thread title if your issue has been.
Search |
FAQ |
RTM
Reynaldo
Halfop
Posts: 54 Joined: Wed May 11, 2005 2:51 am
Post
by Reynaldo » Sat Aug 13, 2005 2:43 am
it's working now..
thank you guys
Reynaldo
Halfop
Posts: 54 Joined: Wed May 11, 2005 2:51 am
Post
by Reynaldo » Thu Mar 23, 2006 5:48 am
How to made each character from words be different the colour?
Alchera
Revered One
Posts: 3344 Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:
Post
by Alchera » Thu Mar 23, 2006 9:39 am
Reynaldo wrote: How to made each character from words be different the colour?
All is revealed in
Colour and formatting codes .
Add [SOLVED] to the thread title if your issue has been.
Search |
FAQ |
RTM
Reynaldo
Halfop
Posts: 54 Joined: Wed May 11, 2005 2:51 am
Post
by Reynaldo » Thu Mar 23, 2006 8:15 pm
i mean, each caracter will be automatically random the color.
says "botnick" , character "b" "o" "t" "n" "i" "c" & "k". will be random eachother & never same color.
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Thu Mar 23, 2006 10:14 pm
Code: Select all
proc randomcolors str {
set str2 ""
for {set i 0} {$i<[llength [split $str ""]]} {incr i} {
set rdm [expr {[rand 15]+1}]
if {[set token [string index $str $i]] != " "} {
append str2 \003${rdm}$token\003
} {
append str2 $token
}
}
set str2
}
Usage:
set string [randomcolors $string]
Reynaldo
Halfop
Posts: 54 Joined: Wed May 11, 2005 2:51 am
Post
by Reynaldo » Sat Mar 25, 2006 5:49 am
i cant used it on "numbering" ??
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sat Mar 25, 2006 6:14 am
Code: Select all
proc randomcolors str {
set str2 ""
for {set i 0} {$i<[llength [split $str ""]]} {incr i} {
set rdm [expr {[rand 15]+1}]
if {$rdm < 10} { set rdm 0$rdm }
if {[set token [string index $str $i]] != " "} {
append str2 \003${rdm}$token\003
} {
append str2 $token
}
}
set str2
}
Reynaldo
Halfop
Posts: 54 Joined: Wed May 11, 2005 2:51 am
Post
by Reynaldo » Sat Mar 25, 2006 11:03 pm
Thank you verymuch bro Sir_fz
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Sun Mar 26, 2006 8:31 am
You can use this proc, which is much faster:
Code: Select all
proc randomcolors str {
set str2 ""
foreach token [split $str ""] {
set rdm [expr {[rand 15]+1}]
if {$rdm < 10} { set rdm 0$rdm }
if {$token != " "} {
append str2 \003${rdm}$token\003
} {
append str2 $token
}
}
set str2
}