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.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
simo
Revered One
Posts: 1089 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Mon Sep 14, 2020 11:30 am
i was using this nice small tcl wich sets chanset via pub command but somehow doesnt set all chansettings for example this doesnt seem to work:
.chanset ap:repeatl 2:10 60 k:kb 2
it sets the first param only 2:10
Code: Select all
bind pub n|n .chanset pub:chanset
proc pub:chanset {nick uhost hand chan arg} {
foreach {set value} [split $arg] {break}
if {![info exists value]} {
catch {channel set $chan $set} error
} {
catch {channel set $chan $set $value} error
}
if {$error == ""} {
putnow "NOTICE $nick :Successfully set $arg"
} {
putnow "NOTICE $nick :Error setting $arg: [lindex $error 0]..."
}
}
CrazyCat
Revered One
Posts: 1248 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Mon Sep 14, 2020 12:18 pm
The split command cut $args in 5 pieces (split is on " ") and set the first to $set (bad idea of variable name) and the second to $value (bad idea too). The script wasn't thought for complex values.
You can use
scan and a regexp to set $set and $value, or do it in 2 times whith:
Code: Select all
set set [lindex [split $arg] 0]
set value [join [lrange [split $arg] 1 end]]
simo
Revered One
Posts: 1089 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Mon Sep 14, 2020 1:55 pm
excellent tnx CrazyCat
caesar
Mint Rubber
Posts: 3776 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Tue Sep 15, 2020 4:23 am
You shouldn't use
set ,
arg or
args cos they have special meanings in TCL.
Here's a nice trick with
lassign :
Code: Select all
% set text "ap:repeatl 2:10 60 k:kb 2"
ap:repeatl 2:10 60 k:kb 2
% set value [lassign $text mode]
2:10 60 k:kb 2
% puts $mode
ap:repeatl
% puts $value
2:10 60 k:kb 2
Once the game is over, the king and the pawn go back in the same box.
simo
Revered One
Posts: 1089 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Sep 15, 2020 3:01 pm
you mean like this caesar:
Code: Select all
proc pub:chanset {nick host hand chan text} {
set text [lindex [split $text] 0]
set value [lassign $text mode]
if {![info exists value]} {
catch {channel set $chan $set} error
} {
catch {channel set $chan $set $value} error
}
if {$error == ""} {
putnow "NOTICE $nick :Successfully set $text"
} {
putnow "NOTICE $nick :Error setting $text: [lindex $error 0]..."
}
}
CrazyCat
Revered One
Posts: 1248 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Tue Sep 15, 2020 6:17 pm
No, he means (if I'm not wrong):
Code: Select all
proc pub:chanset {nick host hand chan text} {
set value [lassign $text mode]
if {![info exists value] || $value eq ""} {
catch {channel set $chan $mode} error
} else {
catch {channel set $chan $mode $value} error
}
if {$error == ""} {
putnow "NOTICE $nick :Successfully set $text"
} else {
putnow "NOTICE $nick :Error setting $text: [lindex $error 0]..."
}
}
simo
Revered One
Posts: 1089 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Tue Sep 15, 2020 7:16 pm
tnx for that crazycat tried that didnt seem to work properly tho same result of just setting parts of the settings
caesar
Mint Rubber
Posts: 3776 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Wed Sep 16, 2020 12:54 am
Did you add a
putlog line to see what mode and value would be set and what error do you get? Something like:
Code: Select all
putlog "trying to set $mode to $value"
Once the game is over, the king and the pawn go back in the same box.
simo
Revered One
Posts: 1089 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Wed Sep 16, 2020 10:44 am
ive added this caesar but it didnt output anything
putserv "privmsg $chan :trying to set $mode to $value"
CrazyCat
Revered One
Posts: 1248 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Wed Sep 16, 2020 11:04 am
I think you don't know how to debug a script...
Try this code, and copy us the command you type in chan and what happens in party-line
Code: Select all
proc pub:chanset {nick host hand chan text} {
set value [lassign $text mode]
putlog "getting mode: *$mode* and value: *$value*"
if {![info exists value] || $value eq ""} {
putlog "value seems to not be set"
catch {channel set $chan $mode} error
} else {
putlog "ok, value is set"
catch {channel set $chan $mode $value} error
}
putlog "error is *$error*"
if {$error == ""} {
putnow "NOTICE $nick :Successfully set $text"
} else {
putnow "NOTICE $nick :Error setting $text: [lindex $error 0]..."
}
}
Using
.console +d is a good way to see errors. And if an error appear, type
.set errorInfo to have more detals
simo
Revered One
Posts: 1089 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Wed Sep 16, 2020 12:35 pm
tried your last posted code and didnt output any error CrazyCat
CrazyCat
Revered One
Posts: 1248 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Wed Sep 16, 2020 12:42 pm
And what did you get in party-line ?
I can't help you without these infos
simo
Revered One
Posts: 1089 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Wed Sep 16, 2020 12:45 pm
list doesn't contain element 2
while executing
"lreplace $items 2 2"
CrazyCat
Revered One
Posts: 1248 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Wed Sep 16, 2020 12:51 pm
So you have an error, but not in that proc, because there is no lreplace in it.
You'd better give us your full script, or find which of your script did this error.
simo
Revered One
Posts: 1089 Joined: Sun Mar 22, 2015 2:41 pm
Post
by simo » Wed Sep 16, 2020 1:06 pm
cleared all tcls and left only the chanset one and seems to work now