| View previous topic :: View next topic |
| Author |
Message |
Reynaldo Halfop
Joined: 11 May 2005 Posts: 54
|
Posted: Fri Aug 12, 2005 3:24 am Post subject: help wih colour |
|
|
| Code: | | PRIVMSG $chan :\(4\002Hi..\002\) |
how to set with random color? from 1-15 colour
Please help.  |
|
| Back to top |
|
 |
Dedan Master

Joined: 09 Jul 2003 Posts: 260 Location: Memphis
|
Posted: Fri Aug 12, 2005 6:38 am Post subject: |
|
|
[rand 15] returns a random number between 0 and 14
| Code: |
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. |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Fri Aug 12, 2005 12:16 pm Post subject: |
|
|
0 being nothing is probably why he adds 1  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Aug 12, 2005 1:33 pm Post subject: |
|
|
Actually 0 is for white, so I thought he might wanna use it. _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Fri Aug 12, 2005 6:15 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
Reynaldo Halfop
Joined: 11 May 2005 Posts: 54
|
Posted: Sat Aug 13, 2005 2:43 am Post subject: |
|
|
it's working now..
thank you guys |
|
| Back to top |
|
 |
Reynaldo Halfop
Joined: 11 May 2005 Posts: 54
|
Posted: Thu Mar 23, 2006 5:48 am Post subject: |
|
|
How to made each character from words be different the colour?  |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Thu Mar 23, 2006 9:39 am Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
Reynaldo Halfop
Joined: 11 May 2005 Posts: 54
|
Posted: Thu Mar 23, 2006 8:15 pm Post subject: |
|
|
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.  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Thu Mar 23, 2006 10:14 pm Post subject: |
|
|
| Code: | 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: | Quote: | | set string [randomcolors $string] |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Reynaldo Halfop
Joined: 11 May 2005 Posts: 54
|
Posted: Sat Mar 25, 2006 5:49 am Post subject: |
|
|
i cant used it on "numbering" ??  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sat Mar 25, 2006 6:14 am Post subject: |
|
|
| Code: | 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
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
Reynaldo Halfop
Joined: 11 May 2005 Posts: 54
|
Posted: Sat Mar 25, 2006 11:03 pm Post subject: |
|
|
| Thank you verymuch bro Sir_fz |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Sun Mar 26, 2006 8:31 am Post subject: |
|
|
You can use this proc, which is much faster:
| Code: | 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
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
|