View Single Post
09-01-20, 09:53 PM   #17
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi all

@MunkDev; I can almost guarantee that my code is flawed and likely very inefficient; I am self-taught with no background in coding at all.

@Seerah; thanks for detailing how the table laid out, this was extremely helpful as it really showed how I was using some tables wrong.

@Fizzlemizz; thanks for the example code, this put Seerah's explanation into action and has been a massive help in the way I approach tables and frames.

Just a follow-up question;

Is this chunk;
Lua Code:
  1. local frameA = CreateFrame("Frame", frameA, UIParent)
  2. frameA.Button1 = CreateFrame("Button", frameAButton1, frameA)
  3. frameA.Button1:ClearAllPoints()
  4. frameA.Button1:SetPoint("CENTER", 0, 0)
  5. frameA.Button1:SetSize(40, 40)
the same as;
Lua Code:
  1. local frameA = CreateFrame("Frame", frameA, UIParent)
  2. frameAButton1 = CreateFrame("Button", frameAButton1, frameA)
  3. frameAButton1:ClearAllPoints()
  4. frameAButton1:SetPoint("CENTER", 0, 0)
  5. frameAButton1:SetSize(40, 40)

In the first chunk, I add the button and the button properties directly to the frame.

In the second I add the button to the frame and then add the properties to the button itself.

Both chunks seem to work but I do not know which one is the proper/correct way of coding this.
  Reply With Quote