Thread Tools Display Modes
12-03-10, 05:15 AM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Pull a table value when the value is a table?

It may be the fact I'm tired, but for the life of me I can't get this to work:

lua Code:
  1. -- generic format
  2. CFM_Profiles[realm][toon] = {}
  3.  
  4. -- create dropbox values
  5. function CFM_LoadDropInit(self)
  6.     local level = level or 1
  7.     local info = UIDropDownMenu_CreateInfo()
  8.    
  9.     local i = 0
  10.     for realm, name in pairs(CFM_Profiles) do
  11.         info.text = realm.. " - ".. name  --  line 1363
  12. -- code snipped
  13. end

Code:
Error occured in: Global
Count: 1
Message: ..\AddOns\CFM\CFM_GUI.lua line 1363:
   attempt to concatenate local 'name' (a table value)
I'm simply looking to pull the text of the value from the table rather than reference it (i.e. toon should be "ChaosInc").
  Reply With Quote
12-03-10, 05:30 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Every table is a list of keys and values. In a multidimensional table, it's a base table with additional tables as values to add depth. To get the keys in the second dimension in this case, you need to put in a nested loop iterating through the retrieved table.
lua Code:
  1. -- generic format
  2. CFM_Profiles[realm][toon] = {}
  3.  
  4. -- create dropbox values
  5. function CFM_LoadDropInit(self)
  6.     local level = level or 1
  7.     local info = UIDropDownMenu_CreateInfo()
  8.    
  9.     local i = 0
  10.     for realm, list in pairs(CFM_Profiles) do
  11.         for name, data in pairs(list) do
  12.             info.text = realm.. " - ".. name  --  line 1363
  13. --          Finish what you need to do
  14.         end
  15.     end
  16. end
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 12-03-10 at 05:32 AM.
  Reply With Quote
12-03-10, 08:00 AM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Yep, I'm just that tired. I used exactly that elsewhere. Thanks. I need a nap.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Pull a table value when the value is a table?

Thread Tools
Display Modes

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