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.
Old posts that have not been replied to for several years.
-
b
badfreman
Post
by badfreman »
i have a list of about 20 words and wish to be able to pick 1 at random and add it to some fixed text being sent to $chan how would i got about this
-
Wcc
- Master
- Posts: 278
- Joined: Sun Oct 28, 2001 8:00 pm
- Location: USA
-
Contact:
Post
by Wcc »
Code: Select all
set rand [lindex $list [rand [llength $list]]]
-
b
badfreman
Post
by badfreman »
what is wrong with this i get
Tcl error [fosters]: can't read "rand": no such variable
set list {
"cool"
"cold"
"refreshing"
"delightfull"
"beautifull"
"splended"
"stunning"
"wicked"
"tastfull"
"nice"
"wonderfull"
"magnificent"
"georgious"
"lovely"
"class"
}
set rand [lindex $list [rand [llength $list]]]
bind pub - !fosters fosters
proc fosters {nick host handle chan text} {
puthelp "PRIVMSG $chan :01ACTION gives 4$nick 12a $rand pint of fosters"
}
-
b
badfreman
Post
by badfreman »
not to worry i have found the answear in a previous post
set list {
"cool"
"cold"
"refreshing"
"delightfull"
"beautifull"
"splended"
"stunning"
"wicked"
"tastfull"
"nice"
"wonderfull"
"magnificent"
"georgious"
"lovely"
"class"
}
bind pub - !fosters fosters
proc fosters {nick host handle chan text} {
global list
puthelp "PRIVMSG $chan :01ACTION gives 4$nick 12a [lindex $list [rand [llength $list]]] pint of fosters"
}
-
Wcc
- Master
- Posts: 278
- Joined: Sun Oct 28, 2001 8:00 pm
- Location: USA
-
Contact:
Post
by Wcc »
You didn't global the 'rand' variable

-
b
badfreman
Post
by badfreman »
thanks for you help this in my script has realy improved my script