Normally for a small addon (like 3 buttons) you would only use 1 .lua file.
The information in the .toc is used by the game to “know” things about the addon. Eg. the ## Interface:
is used to determine if your addon will show as out-of-date in the addons list.
Most of this you can get back into your addon through the API.
Game API (it is quite extensive)
https://warcraft.wiki.gg/wiki/World_of_Warcraft_API
Something a bit larger with a “home” for some buttons.
local f = CreateFrame("Button", "TiffanyTest", UIParent, "BasicFrameTemplateWithInset")
f:SetSize(400, 150)
f:SetPoint("CENTER")
f.Title = f:CreateFontString("$parentTitle")
f.Title:SetFontObject(GameFontNormal)
f.Title:SetText("Home for My First Addon!")
f.Title:SetPoint("TOP", 0, -4)
for i = 1, 3 do
local b = CreateFrame("Button", "$parentButton"..i, f, "UIPanelButtonTemplate")
f["Button"..i] = b
b:SetSize(100, 40)
b:SetText("Click Button " ..i)
b:SetScript("OnClick", function(self)
print(self:GetName())
end)
if i == 1 then
b:SetPoint("TOPLEFT", f.InsetBorderTopLeft, 5, -2)
else
b:SetPoint("LEFT", f["Button"..i-1], "RIGHT", 5, 0)
end
end
local function DoSomethingOnClick(self)
print(self:GetName(), "Just another click!")
end
f.AnotherButton = CreateFrame("Button", "$parentAnotherButton", f, "UIPanelButtonTemplate")
f.AnotherButton:SetSize(100, 40)
f.AnotherButton:SetText("Another Button")
f.AnotherButton:SetPoint("BOTTOM", 0, 8)
f.AnotherButton:SetScript("OnClick", DoSomethingOnClick)
If you have large groups of code doing different things you might modularise the addon multiple files is probably more of a pain when you’re getting started.
If you type /fstack
and move your mouse over the frame you can see some information about the frame (and every frame the mouse is over) and its buttons /fstack
to turn it off again.