From what I gather from your description...Dedan wrote:something like this:
inc -s30 color blue
It would "set" the var "color" as "blue", (if one does not exists)
other wise it would set the exisiting var to last 30 seconds, then 30 seconds later, unset itself.
It would replace 3 lines of script and 3 commands.
"s" switch to call seconds
"m" swtich to call minutes
all this:
set var
increase var
timer unset var
unset var
gets to be boring
tcl for eggdrop needs to move forward.
5 or 6 new commands added into a
tools module would be nice
Code: Select all
proc inc {switch var value} {
global $var
if {![info exists $var]} { set $var $value }
regexp -- {-(s|m)(.*)} $switch garbage type ttime
switch $type -- {
"s" { utimer $ttime [list unset $var] }
"m" { timer $ttime [list unset $var] }
}
}
I don't think a module is needed. How about adding a couple of procs/aliases to alltools or some other tcl that comes with eggdrop?Dedan wrote:I will hire someone to write a module with new commands.
What did you mean by that?Dedan wrote:inc, remove (-nocase string,substring), and whatever else i find annoying.
From the description he gave, global is what he would want for the proc (as it is a global variable he is setting from my understanding).user wrote: Btw: if you're gonna use that inc proc strikelight gave you you better make sure you never use a variable name used in the proc. (or change that 'global' line to use 'upvar' instead) And don't inc a var again before the previous timer ends or you'll have timer errors all over (trying to unset a non existant var)
Code: Select all
proc safeunset {var} {
global $var
catch {unset $var}
}
proc inc {switch var value} {
global $var
if {![info exists $var]} { set $var $value }
regexp -- {-(s|m)(.*)} $switch garbage type ttime
switch $type -- {
"s" { utimer $ttime [list safeunset $var] }
"m" { timer $ttime [list safeunset $var] }
}
}
Yes...but your code would screw up if he was trying to manipulate a global variable by the same name used inside your proc (several to chose from)strikelight wrote:From the description he gave, global is what he would want for the proc
Code: Select all
upvar #0 var blah
Code: Select all
upvar <any valid level> ::var blah
There is no way it could screw up, as "var" is the local variable, $var (ie. The CONTENTS of var) is the global.user wrote:Yes...but your code would screw up if he was trying to manipulate a global variable by the same name used inside your proc (several to chose from)strikelight wrote:From the description he gave, global is what he would want for the proc
Yes I am aware of this, but it is not completely compatible across the entire (older) eggdrop/tcl line.user wrote: Upvar can be used to import global variables too you know...orCode: Select all
upvar #0 var blah
Code: Select all
upvar <any valid level> ::var blah
I see what you are saying now..What you should have said is "inc'ing global variable names that are the same as variable names included in the proc itself"user wrote:Good luck trying to 'inc' any of these using your proc: switch, var, value, garbage, type and ttime.strikelight wrote:There is no way it could screw up, as "var" is the local variable, $var (ie. The CONTENTS of var) is the global.
Code: Select all
proc safeunset {__var} {
global $__var
catch {unset $__var}
}
proc inc {__switch __var __value} {
global $__var
if {![info exists $__var]} { set $__var $__value }
regexp -- {-(s|m)(.*)} $__switch __garbage __type __ttime
switch $__type -- {
"s" { utimer $__ttime [list safeunset $__var] }
"m" { timer $__ttime [list safeunset $__var] }
}
}