|
CDS Beginner
Joined: 31 May 2003 Posts: 15 Location: USA
|
Posted: Fri Jun 06, 2003 3:07 am
Variable handling in Inherited file |
Hi,
What is the correct way to set up and use variables in an inherited file?
I'm trying to write an automatic equipment database filler that grabs info from auctions and identify spells. I wrote it in the inherited file so different characters could all gather info for the database (all are played on the same MUD). The triggers and aliases work as expected, but the variables.....
First, though I created them in the inherited file, each time the script ran, variables of the same name appeared in the primary file. The variables in the primary file contained the info, and the ones I had created earlier with the editor in the inherited file were empty. So I deleted all of them (primary and inherited), and wrote an initialization script to create the variables itself using this type of script in the inherited file:
#VAR db {} _nodef EqDatabase
#VAR Level {-1} _nodef EqDatabase
where EqDatabase is a class in the inherited file only. Now each time an item is recorded, another copy of SOME of the variables appear multiple times in the Primary file version of Eqdatabase. For example, after 6 identifies, I'll have 1 copy of Level and 6 copies of db (both initialized in the same place at the same time using the script above by an alias in the inherited file). These variables don't appear in the inherited file anywhere, but in the primary file's copy of the inherited Eqdatabase class. That's ok - they do seem to work, but the multiple copies aren't going to fly! : )
Another big problem with the variables, is that one (so far - I plan a few more) of the variables is a user-defined function. I wrote it in the EqDatabase class in the inherited file. It's called from the same class. But a #say (in the function, but does not fire) shows it isn't even accessed.
I also tried #Gvar with no luck. This test script is written in the inherited file:
#class 0
#var TestVarN1 {main}
#Gvar TestVarG1 {main G}
#class Eqdatabase
#var TestVarN2 {Eqdb} _nodef EqDatabase
#Gvar TestVarG2 {Eqdb G} _nodef EqDatabase
and creates TestVarN1 in the root directory of the primary file, and TestVarN2 in the primary file's version of EqDatabase (When I say 'version', I mean the way that classes normally appear when they've been inherited. I haven't made local copies of the EqDatabase class in the primary files. Is that the problem?). The Gvar commands didn't seem to do anything. I can't find TestVarG1 or TestVarG2 in either the primary or the inherited files.
FYI, the EqDatabase class is inherited and has "Set as default when executed" turned on, and I'm running Version 6.62.
I looked all over the help file and searched the forums here, but can't find any answers. What am I doing wrong or what have I missed? Sorry to be so long, but I though it might help if you knew what I'd tried already.
Thanks! |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Jun 06, 2003 5:03 am |
Why does it matter where the variables are? They are only temporary storage. The database is your permanent record of the information.
Since your script changes these variables they need to be in your primary settings files, preferably in the None class.
LightBulb
Advanced Member |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Fri Jun 06, 2003 11:59 am |
User-defined functions do not execute commands except by using the %exec function.
Kjata |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|