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.

$ch r(3) $+ $r(1,7)

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
KhashayaR
Voice
Posts: 22
Joined: Thu Jul 19, 2007 9:34 pm
Location: World
Contact:

$ch r(3) $+ $r(1,7)

Post by KhashayaR »

hello :) is it possible to have translate $ch r(3) $+ $r(1,7) to TCL language? this will give a random color to output text Thanks in advance
===
IRC Network: DALnet
Nick: KhashayaR
===
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Simplest way:

Code: Select all

set col [format "%.02d" [expr {1 + round(rand()*6}]]
set ch "\003${col}"
Note that IRC colors goes from 0 (white= to 15). If you want to use all of them but the white, change the "6" to 14.
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

this seems to work for me but i was wondering if only certain random colors could be used for foreground and background

Code: Select all

bind pub n|n  .rcols random:cols

proc random:cols {nick host hand chan text} {
  putquick "privmsg $chan \00300,[expr {int(6*rand() + 1)}] $text \017" 
 }
if possible i was curious how to use the following config:

for foreground i would like to use:
00 08 09 11 15
for background i would like to use:
01 02 03 04 05 06 07 10 12 14
this is the msl version:
$+($chr(3),$base($gettok(00 08 09 11 15,$r(1,5),32),10,10,2),$chr(44),$base($gettok(1 2 3 5 6 7 10 12 14,$r(1,9),32),10,10,2))
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Create a list of bg colors and a list of fg colors and select random in each.

Code: Select all

set fg {00 08 09 11 15}
set bg {01 02 03 04 05 06 07 10 12 14}
proc colors {} {
   set mfg [lindex $::fg [rand [llength $::fg]]]
   set mbg [lindex $::bg [rand [llength $::bg]]]
   return "\003${mfg},${mbg}"
}
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

excellent crazycat that worked i was wondering if this could be called by other tcl scripts for example for kick messages
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

was fiddling with it some more seems to be working fine thanx crazycat
User avatar
KhashayaR
Voice
Posts: 22
Joined: Thu Jul 19, 2007 9:34 pm
Location: World
Contact:

Post by KhashayaR »

Thanks alot guys :)
===
IRC Network: DALnet
Nick: KhashayaR
===
Post Reply