speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Aug 18, 2012 9:24 pm Post subject: Re: mass slap+say script |
|
|
| Code: | if {[llength [lindex $args 0]]<2} {
# becomes to the eggdrop every single time
if {1 < 2 } { |
Here is your problem. "[llength [lindex $args 0]]" will always be 1. It has no choice but to be because of how you've used it in your procedure declaration.
Stop using "[lindex $args 0]" all over the place. Everywhere you have that change it to "[split $arg]".
Also, change this part:
proc msg_say {nick uhost hand args} {
to this:
proc msg_say {nick uhost hand arg} {
There are more errors than this in your script concerning list to string errors. But I will let you figure those out. Only in certain conditions with certain characters should you notice the bugs.
| http://www.peterre.info/characters.html wrote: | A point worthy of note about args
Putting args as the last argument of a Tcl procedure allows the use of a variable number of input arguments. But there is a potential source of confusion if the procedure is one that is called by an eggdrop bind command.
In a script that I downloaded I saw code similar to the following:
bind dcc - m2f dcc_calc_m2f
proc dcc_calc_m2f {hand idx args} {
if {[llength $args] == "1"} {
The author was no doubt thinking that if a user typed
.m2f aaa bbb ccc
then the value of args would be a list of three elements, aaa, bbb and ccc, and that therefore the value of [llength $args] would be 3.
In fact, the value of args would be a list of one element, that element being the string aaa bbb ccc. Whatever string the user types, the value of [llength $args] will always be 1.
Similarly, the value of [lindex $args 0] will not be the string aaa, but the string aaa bbb ccc.
The eggdrop pub and msg binds behave in the same way.
The above properties of eggdrop's bind command have been confirmed by testing with eggdrop version 1.6.6. |
_________________ speechles' eggdrop tcl archive |
|