So what I wanted to accomplish was to build a table like so:
Code:
function buildatable(saveType)
local temptable = {}
local numitems = getNumItems() -- inconsequentially named function,
-- this refers to a function that simply outputs the number of different
-- items in the array I am attempting to save the values of
for item = 1, numitems, 1 do
-- here I assign things to the temptable and iterate through with more for
-- loops and more table declarations like temptable[item].subitems = {}
-- Eventually this becomes a very large multi-dimensional array of data.
end
if saveType == "Global" then
myGlobalVarReference.table = temptable -- this does not work
else
myPerCharacterVarReference.table = temptable -- this also does not work
end
end
Then, as the above code suggests, get an entire table to inject into the saved vars table, For the life of me I cannot find a native function to do so (so far)
I have little time today but I thought of a decent idea to instead of passing the variable saveType to call this function from within a function and pass the reference to which table to inject this data into into. Is that a feasable option?
something like
Code:
function beforebuildatable(saveType)
if saveType == nil then
saveType = myPerCharacterVarReference.saveType
end
if saveType == "Global" then
buildatable(myGlobalVarReference.table) -- use global reference
else
buildatable(myPerCharacterVarReference.table)
end
end
function buildatable (table) -- use same code as above but
-- instead build the table inside the referenced table instead of injecting
Will this work?
Note: I have really shorthanded all of this, but I believe that the basic concept can be easily read (correct me if I'm wrong) I do not have access to the real code at this time.