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.

Random Text Grabber [Solved]

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
kris
Voice
Posts: 14
Joined: Tue Sep 12, 2006 10:46 am
Location: Perth, Australia
Contact:

Random Text Grabber [Solved]

Post by kris »

Basically, it grabs the text from the variable and displays it, its a simple love script.

Code: Select all

bind pub -|- `random pub_random
proc pub_random {nick host hand channel text} {
global reply
putquick "PRIVMSG $channel \00306* $nick would like to send $text :[lindex $reply [rand [llength $reply]]]"
}
set reply [list "\"A Box of chocolates\"" "\"a single white rose\"" "\"A pile of dog poo\"" "\"Nothing, Dump them!\"" ]
The error it comes up with is:
[00:49] Tcl error [pub_random]: wrong # args: should be "rand"[/code]
Last edited by kris on Mon Nov 06, 2006 12:23 am, edited 1 time in total.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Got any scripts that might've renamed rand?
(hint, search all your scripts for "rename rand")
NML_375
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

You don't need to have the "set reply" outside of the proc, just put it above the putquick. And use this kind of format:

Code: Select all

set reply {
{Whatever reply}
{2nd reply}
{Reply three}
}
That's what I use anyway, there's more than one way to do random stuff like this.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

@rosc:
Actually, using [list ...] to generate lists is preferred to trying to craft your own list structures by hand...
Anyway, the error at hand here is that "rand" seems to have been replaced by a different function/proc that does'nt take a "limit"-value
NML_375
User avatar
kris
Voice
Posts: 14
Joined: Tue Sep 12, 2006 10:46 am
Location: Perth, Australia
Contact:

thanks.

Post by kris »

ill have a look, ill see what there is to fix, if their is another one ill remove it, ive made a few different ones, but ill try.

Kris
Post Reply