Addon Progress and More Addon Questions

Well I’ve made some progress. I now have two buttons on MyAddon, each with a separate .lua file. I made one wider than the other I added a second directory with my NxAddon which has a 3rd button. I moved it to the right.

So my next question, are the ## lines just comments? At first I didn’t think so because it talks about having to have the right version number and that’s the only place you put it. But I deleted all my ## lines and it still works.

Also, what I’ve done is fun but is there a manual some place that tells you what all the functions are that you can call and what information you can access?

Thanks :slight_smile:

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.

Wow !!! (the interjection, not the game).
Reading that list gives you that kid in a candy store feeling.

If you didn’t come across it, aside from looking at other addons, you can extract the entire default game UI code to your PC (or view on the web).
https://warcraft.wiki.gg/wiki/Viewing_Blizzard%27s_interface_code

There is lots of stuff you can repurpose in your addon(s) but one thing to remember, Blizz. can do things that are various levels of “secure” that addons either can’t do or, have to do in a different way to achieve a useful outcome. Most are to do with performing actions in combat but some of this flows into other areas as well.

Have fun!

1 Like