The .toc is essentially a catalogue card that lists some information about the addon and has a list of files that contain the code (lua and xml) that make up the addon.
https://wow.gamepedia.com/World_of_Warcraft_API
is probably the most consistent source of addon information available but the subject is large and ever evolving and the approaches to creating them is so varied there is no “one approach fits all” quick list.
A few starter points, the .toc file has to be the same name as the folder it is in (the folder directly under \Interface\Addons
).
XML templates (with the virtual attribute) are inherited using their name eg. the game has a default virtual template for the standard red button. To inherit it in XML you add inherits="UIPanelButtonTemplate"
attribute to your XML frame declaration or use it in the 4th parameter of CreateFrame
local f = CreateFrame("Button", "MySpecialButton", UIParent, "UIPanelButtonTemplate")
All frame names (including virtuals) are global so make sure yours are unique.
Frames don’t have a size, are not placed on-screen or display anything by default (inherited templates can supply these defaults or it can be done in code).
When you add new (or rename) files (code, art, sound etc. they will not be available in-game until you completely exit the game and re-start.
You can export the Blizzard UI code to peruse:
https://wow.gamepedia.com/Viewing_Blizzard%27s_interface_code
Install a debugger, it will make your life easier:
BugGrabber and BugSack work together.
https://www.curseforge.com/wow/addons/bugsack
https://www.curseforge.com/wow/addons/bug-grabber
A quick addon to create a button that inherits the in-game red button template, anchors it to left of screen and prints some text when clicked. (you can paste the code into the website addon.bool.no
to create/download the “addon”)
local f = CreateFrame("Button", "MySpecialButton", UIParent, "UIPanelButtonTemplate")
f:SetSize(70, 25)
f:SetText("Hellooo!")
f:SetPoint("LEFT", UIParent, "LEFT", 10, -20)
f:SetScript("OnClick", function(self) print(self:GetText(), self:GetName(), "was just clicked") end)
You don’t NEED XML to create a frame, it can all be done in lua.
A simple frame anchord to the right of screen filled with an all white texture that is set to yellow:
local sqr = CreateFrame("Frame", nil, UIParent)
sqr:SetSize(50, 50)
sqr:SetPoint("RIGHT", UIParent, "RIGHT", -20, 0)
sqr.Texture = sqr:CreateTexture()
sqr.Texture:SetAllPoints()
sqr.Texture:SetTexture("Interface/BUTTONS/WHITE8X8")
sqr.Texture:SetVertexColor(1, 1, 0)
And you don’t NEED lua or templates (virtuals) to actually create/display a frame in-game.
The yellow square above in XML
<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/">
<Frame name="FizzleXFRAME" parent="UIParent">
<Size x="50" y="50" />
<Anchors>
<Anchor point="RIGHT" x="-20" y="0" />
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<Texture parentKey="Texture">
<Color r="1" g="1" b="0" a="1"/>
<Anchors>
<Anchor point="TOPLEFT" />
<Anchor point="BOTTOMRIGHT" />
</Anchors>
</Texture>
</Layer>
</Layers>
</Frame>
</Ui>