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.

Writing something with a delay

Help for those learning Tcl or writing their own scripts.
Post Reply
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Writing something with a delay

Post by darton »

Hello!
When somebody in the channel writes a certain command, my bot should write something back and after 15 seconds a second message. So I made this script but there must be something wrong, because an error occurs: "can't read "chan": no such variable"

Code: Select all

bind pub - !test test
proc test {nick uhost hand chan arg} {
putserv "PRIVMSG $chan :Test"
utimer 15 { putserv "privmsg $chan : Test" }
}
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

the utimer script executes outside the proc context, therefore $chan is not available for evaluation at execution time

the usual solution to this problem is to force evaluation of $chan inside the proc:

Code: Select all

utimer 15 [list putserv "privmsg $chan :test"]
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
d
darton
Op
Posts: 155
Joined: Sat Jan 21, 2006 11:03 am

Post by darton »

OK, thank you. It works.
Post Reply