PDA

View Full Version : Table Structures


ToyImp
15-07-2007, 08:46 PM
I'm trying to get a variable to be saved and I keep getting an error:: attempt to index field '?' (a string value)

with this::

CharacterData[TargetName][TargetClass] = UnitClass("playertarget")

I can get the TargetName to write without having the class. But how do I add another layer to the table?

The savedvariables file should look like this::

That's not what I need it to do though. I need it so that in the saved variable's the class of a players name will be found. So the class variable is going to be saved many times.


SavedVariables = {
["Xerexes'] = {
["Class"] = "Warlock"
["Level"] = "70"
}
}

Telic
16-07-2007, 07:38 PM
Difficult to say why you are having a problem. The most obvious issue would be that you have not defined CharacterData[TargetName] as an array before trying to add further variables.

In other words, then where :
TargetName = "Xerexes"
&
TargetClass = "Class"
then you MUST set

CharacterData[TargetName] = {}

BEFORE you can set

CharacterData[TargetName][TargetClass] = UnitClass("playertarget")


This is assuming the "code" showing the array structure is what you are aiming for...