Thread Tools Display Modes
Prev Previous Post   Next Post Next
03-10-21, 05:07 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Table inside of a table getting a value

Hi all

I have a table within a table where I need to access a value to build a button.

So far I can build the buttons successfully and they display their value, however, when click the button to use that value to print a message only the top button prints the expected string, the second prints nothing, and each subsequent button prints nil.

Here is my chunk;
Lua Code:
  1. DeathKnightChatScrollFrame.buttons = {}
  2. for index = 1, NumberList.scrollButtonNumber do
  3.     DeathKnightChatScrollFrame.buttons[index] =
  4.         CreateFrame("Button", "btn" .. index, DeathKnightChatScrollParent, "OptionsListButtonTemplate")
  5.     button = DeathKnightChatScrollFrame.buttons[index]
  6.     button:SetSize(NumberList.scrollSpellFrameWidth, NumberList.phraseTextButtonHeight)
  7.     button:SetPoint("TOPLEFT", 8, -(index - 1) * NumberList.phraseTextButtonHeight - 8)
  8.     button:SetScript(
  9.         "OnClick",
  10.         function(self)
  11.             print("Test Print -  ", DeathKnightSpellList[self.index].spellChatList[index], index) -- debug --
  12.         end
  13.     )
  14. end

This is the table layout;


These are the print results;


My questions are why can I not grab the string values using the following syntax,
Lua Code:
  1. DeathKnightSpellList.spellChatList[self.index]

And what is the proper syntax to correctly use the string value in the second table?
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Table inside of a table getting a 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