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:
DeathKnightChatScrollFrame.buttons = {}
for index = 1, NumberList.scrollButtonNumber do
DeathKnightChatScrollFrame.buttons[index] =
CreateFrame("Button", "btn" .. index, DeathKnightChatScrollParent, "OptionsListButtonTemplate")
button = DeathKnightChatScrollFrame.buttons[index]
button:SetSize(NumberList.scrollSpellFrameWidth, NumberList.phraseTextButtonHeight)
button:SetPoint("TOPLEFT", 8, -(index - 1) * NumberList.phraseTextButtonHeight - 8)
button:SetScript(
"OnClick",
function(self)
print("Test Print - ", DeathKnightSpellList[self.index].spellChatList[index], index) -- debug --
end
)
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:
DeathKnightSpellList.spellChatList[self.index]
And what is the proper syntax to correctly use the string value in the second table?