Thread Tools Display Modes
Prev Previous Post   Next Post Next
08-29-13, 08:35 AM   #1
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Getting and Setting a tabled value

Basically I have a table of strings that are the same as the index to a saved variables table.

I'm not sure how to go about writing the proper function to set and get the values in of the saved variable table using the table of strings.

Lua Code:
  1. local example = {
  2.     profile = {
  3.         helper = {
  4.             enable = true,
  5.         }
  6.     }
  7. }
  8.  
  9. local index = {
  10.     "profile",
  11.     "helper",
  12.     "enable"
  13. }
  14.  
  15. local function GetValue(t) -- This Seems to work
  16.     if type(t) == "table" then
  17.         local DB
  18.         for k, v in next, t do
  19.             if not DB then
  20.                 DB = example[t[k]]
  21.             else
  22.                 DB = DB[t[k]]
  23.             end
  24.         end
  25.         return DB
  26.     else
  27.         return example[t]
  28.     end
  29. end
  30.  
  31. local function SetValue(t, val)
  32.      -- Do things here???
  33. end
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Getting and Setting a tabled value


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