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.

Global variables?

Old posts that have not been replied to for several years.
Locked
Q
QKill
Voice
Posts: 6
Joined: Mon Aug 09, 2004 9:09 am
Location: Stockholm, Sweden
Contact:

Global variables?

Post by QKill »

Hi everybody!

Is variables in a scriptfile isolated from all other scripts or is all variables global?

If i for exampel load a script multiple times, will the variables overwrite each other? It is is, is there someway to avoid that?

Thanks!

// Peter
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

You can load scripts into a different namespace or interpreter if you want to avoid name conflicts, but the scripts will have to be written to handle their new environment.

Code: Select all

namespace eval ::demo {
  source some.tcl
}
(the code in some.tcl will be evaluated inside the ::demo namespace)
Have you ever read "The Manual"?
Q
QKill
Voice
Posts: 6
Joined: Mon Aug 09, 2004 9:09 am
Location: Stockholm, Sweden
Contact:

Post by QKill »

Ok, thanks!

The thing is that i want to use the script as a service for several teams on quakenet. So every script should have their own settings, and i want to avoid installing a new eggdrop for every team that will use it.

Its like the warmanager script, but much more functions.

So i dunno whats the best. To make a new namespace for each script, or to make it dynamic to support several channels/settings.

// Peter
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Making a single script support several channels would of course be much better. Less hassle dealing with binds etc. (some binds are not stackable, so the script loaded last would "win")
But that doesn't mean using your own namespace is a bad idea. :)
Have you ever read "The Manual"?
Locked