egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
KhashayaR
Voice


Joined: 19 Jul 2007
Posts: 22
Location: World

PostPosted: Fri Nov 27, 2020 6:43 am    Post subject: $ch r(3) $+ $r(1,7) Reply with quote

hello Smile 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
===
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Fri Nov 27, 2020 8:11 am    Post subject: Reply with quote

Simplest way:
Code:
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.
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Fri Nov 27, 2020 11:34 am    Post subject: Reply with quote

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

Code:

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:
Quote:
00 08 09 11 15


for background i would like to use:
Quote:
01 02 03 04 05 06 07 10 12 14


this is the msl version:

Quote:
$+($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))
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Fri Nov 27, 2020 1:28 pm    Post subject: Reply with quote

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

Code:
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}"
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Fri Nov 27, 2020 2:17 pm    Post subject: Reply with quote

excellent crazycat that worked i was wondering if this could be called by other tcl scripts for example for kick messages
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 941

PostPosted: Fri Nov 27, 2020 4:09 pm    Post subject: Reply with quote

was fiddling with it some more seems to be working fine thanx crazycat
Back to top
View user's profile Send private message
KhashayaR
Voice


Joined: 19 Jul 2007
Posts: 22
Location: World

PostPosted: Sun Nov 29, 2020 10:32 am    Post subject: Reply with quote

Thanks alot guys Smile
_________________
===
IRC Network: DALnet
Nick: KhashayaR
===
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber