Instead of blaming creator you can just point him to right direction.
So. To make your addon work you must have at least 3 files:
- *.txt
- *.xml
- *.lua
txt contains information about your addon with addon file list.
xml contains your addon structure anu UI.
lua contains lua code.
So, 1st of all you need to initialize it.
There are several ways of doing it.
1: initialise through xml
2. initialise through event
Both ways are serving one purpose: initialise your addon, but have some difference in use.
When initialising through xml you will have to create TopLevelWindow and link it to event named
OnInitialized. It has attribute: self. You do not need it now, beacuse this addon do not use methods. ("Self" will be a reference to object, this function was triggered from)
When initialising through lua you will have to link your addon to event EVENT_ADD_ON_LOADED. It's a little harder, so you can read it yourself
here.
In this example we will initialise through XML.
<GuiXml>
<TopLevelWindow name="SuperAddonTopWindow">
<OnInitialized>
AddonStart(self)
</OnInitialized>
</TopLevelWindow>
</GuiXml>
So, when your XML file (part of it) is loaded, this function (AddonStart) will be called from lua file.
Now you can save this xml file and start lua.
1st of all, you need to create function, you want to call from your xml file: AddonStart.
There are several ways to do it:
1st:
2nd:
Lua Code:
AddonStart=function ()
end
I prefer 1st one.
So, let's place some cool stuff incide this function.
Lua Code:
function AddonStart()
--you wont see this text, because it will be shown before player chat sreen loads. Btw, this is comment :)
--and "d()" will display some text to the chat
d("Addon Started!")
SLASH_COMMANDS["/showfps"] = ShowFpsHandler
end
We just registered you addon command. When you enter "/showfps", ShowFpsHandler() function will be called. It will say to the game, what to do next.
Lua Code:
function ShowFpsHandler(text)
if text =="" then
-- ".." allows you to unite text and variable. "tostring" converts any value to text.
-- Now define local variable and make it equal to result of ingame function GetFramerate()
-- It is already implemented by developers and allowed to use :)
local CurrentFps=GetFramerate()
d("Current Fps: "..tostring(CurrentFps))
else
d("What? There's no such command! Go away!")
end
Now, you have to make working addom from all this stuff