Thread Tools Display Modes
Prev Previous Post   Next Post Next
08/03/15, 08:28 PM   #1
Talen-Shei
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 6
Issue with saving

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.
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Issue with saving


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off