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.

TCL error: wrong # args error.

Help for those learning Tcl or writing their own scripts.
Post Reply
s
stafu
Voice
Posts: 2
Joined: Thu Oct 02, 2008 4:41 am

TCL error: wrong # args error.

Post by stafu »

Hey guys. I'm very new to TCL and I'm trying to make a scissors paper rock script. However when I message my choice to the bot it gets this error:

[16:42] Tcl error [spr:setweapon]: wrong # args: should be "spr:setweapon nick host handle chan arg"

Here are the bits of code that relate to the bit that's getting the error:

Code: Select all

bind msg 	- 	spr	spr:setweapon

proc spr:setweapon {nick host handle chan arg} {
    global botnick spr_player1 spr_player2 spr_started spr_playerstat spr_player1_w spr_player2_w
    if {$spr_started == 0} {
        puthelp "PRIVMSG $chan :Game not running. Type !spr <nick> to play."
        return 0
    }
	if {$arg == ""} {
		puthelp "notice $nick :You need to /msg $botnick <scissor, paper or rock>"
	}
	if {$nick == $spr_player1} {
		if {$arg == "scissor"} {
			set spr_player1_w scissor
		}
		if {$arg == "paper"} {
			set spr_player1_w paper
		}
		if {$arg == "rock"} {
			set spr_player1_w rock
		}		
	}
	if {$nick == $spr_player2} {
		if {$arg == "scissor"} {
			set spr_player2_w scissor
		}
		if {$arg == "paper"} {
			set spr_player2_w paper
		}
		if {$arg == "rock"} {
			set spr_player2_w rock
		}		
	}
	spr:checkwin
}
I'm sure it's not the cleanest way to do what I'm trying to do, but at the moment I'm just testing/playing, but I can't work out why it's giving me that error. I've tried a bunch of different things and there's still always some problem.

Any ideas?
F
Furbs
Voice
Posts: 7
Joined: Wed Oct 01, 2008 9:16 pm
Location: Adealide, South Australia, Australia
Contact:

Re: TCL error: wrong # args error.

Post by Furbs »

try like

Code: Select all

proc spr:setweapon { nick host hand chan {arg ""} } {
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

One suggestion, msg bindings do not provide a channel-argument, so remove that from your proc-head...
See the doc/tcl-commands.doc file that comes with your eggdrop for further details regarding different commands and bindings.

Code: Select all

proc spr:setweapon {nick host hand arg} {
NML_375
s
stafu
Voice
Posts: 2
Joined: Thu Oct 02, 2008 4:41 am

Post by stafu »

Thanks guys. Taking out the chan arg fixed it. :)
Post Reply