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.

Timed Vars

Old posts that have not been replied to for several years.
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Timed Vars

Post by Dedan »

When writting scripts for IRC, there is a great need for timed Vars.
How come a timed Var command has not been intergrated into a module for eggdrop?
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

i'm sorry, but could you explain what a "timed Var" is ? a var with a limited existing time ? if yes : try a utimer with unset
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

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 8)
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Dedan wrote:inc -s30 color blue
Unlearn the mIRC way of thinking. I'm sure what you want can be done in several other ways without this stupid "feature". Or you could make a small proc that makes a timed variable just like that if you refuse to unlearn :P
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

tcl was not written for IRC, therefore it needs to be adapted.
tcl has no commands directly related to IRC,
only the modules that have been made by our friends at eggdrop.
Why go threw 3-4 commands that were not made for IRC,
when 1 new command can do it?

I have seen your posts user, it is very apparent that
you are a true master at scripting in tcl,
you have a vast wealth of scripting skills.

But the rest of us are struggling with commands
that were never intended to govern chatrooms.

5 or 6 new commands could help many, in the present and
future, to focus on new scripts instead of dealing with commands
that where never intended for IRC bots.

You may be a better scripter at mIRC than I.
If so, then you know that there are commands that
handle vars, timed vars, bans, and strings with ease.
What is wrong with eggdrop adding new commands to handle
the basic needs of scripters?

There is usually a better way to do something,
computer languages usually grow or are left behind.

There will come a day when even C is will be a second
choice to a more advanced language.

What is wrong with a new tools module for eggdrop?
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

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 8)
From what I gather from your description...

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] }
  }
}
There.. TCL has been expanded for you now... Now you can include that code and use 'inc -s20 color blue' as many times as you'd like...
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

Thank you strikelight, you are a scholar and a gentleman.

But i wanted these new commands for everyone, most new
scripters to eggdrop have no formal training (like me)
and the manuals at tcl are brief with their description
and no examples most of the time.

Scripting for eggdrop is about bots, files, channels, nicks, and text.
TCL was made to control machines, scripting for machines
is about position, time, speed, and cycles.

The bottom line is this:
I love eggdrop and our good friends at eggdrop continue to
advance the program, I take my hat off to you guys.
I want the tcl languge(for eggdrop) to advance too.

I will hire someone to write a module with new commands.

inc, remove (-nocase string,substring), and whatever else i find annoying.

Thanks for all the help i have recieved at this forum.
Without this forum i would know nothing.
As it is, I still know very little about tcl for eggdrop, but i am learning.

Thanks again for all the help.
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

if you want mirc scripting than stick to it
if you want TCL scripting than stick to it

the more stuff like this is added to eggdrops (modular) the more we go away from real TCL. Then slenox would have to to open a "mIRC4eggie Forum", get himself a windows server and host some tiny little mirc / angel / whatever.

Pure TCL would be too hard for the most features, sure, but we dont need to bring in more than the nescessary stuff.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Dedan wrote:I will hire someone to write a module with new commands.
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:inc, remove (-nocase string,substring), and whatever else i find annoying.
What did you mean by that?

What commands do you miss except from 'inc'? You could make a mIRC namespace with all the commands you miss the most and suggest it for inclusion in the next eggdrop release :)

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)


Tiny rant about bloated languages like mIRC script:

Having several commands that do the same thing serves no purpose but bloating the language. And having several commands that do several of the same things just seems insane to me (eg: set, inc & dec in mIRC).
In order to be able to read a script written by someone else you'll have to learn many more commands, but the language doesn't benefit from it in any way. Each command become more bloated and slowed down because there's more options to be checked for and as a "bonus" you get people asking how to decrease a variable in Tcl, because there's no "decr" :P
I could go on about this for a while, but I'll stop and go to bed :)
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

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)
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).
As for the timers ending, and successive inc's generating errors (I don't know what happens in the mIRC command, again just goin by description...), to avoid that simply make it as such:

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] } 
  } 
} 
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

strikelight wrote:From the description he gave, global is what he would want for the proc
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)

Upvar can be used to import global variables too you know...

Code: Select all

upvar #0 var blah
or

Code: Select all

upvar <any valid level> ::var blah
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

user wrote:
strikelight wrote:From the description he gave, global is what he would want for the proc
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)
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: Upvar can be used to import global variables too you know...

Code: Select all

upvar #0 var blah
or

Code: Select all

upvar <any valid level> ::var blah
Yes I am aware of this, but it is not completely compatible across the entire (older) eggdrop/tcl line.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

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.
Good luck trying to 'inc' any of these using your proc: switch, var, value, garbage, type and ttime.
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

user wrote:
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.
Good luck trying to 'inc' any of these using your proc: switch, var, value, garbage, type and ttime.
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" :wink:

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] } 
  } 
} 
It is highly doubtful that the user will be using variables with those names now, while still maintaining compatibility.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

strikelight wrote: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" :wink:
I'm sorry about that... English is not my native language and I'm tired :/
Locked