-
Notifications
You must be signed in to change notification settings - Fork 0
Step02
The .toc-file is a must. This file contains some meta-information about the addon and references our source-files. You can see further information about the .toc here and the file itsself can be found here
## Interface: 40100
## Author: Mischback
## Title: oUF|cffffd700 Splash|r
## RequiredDeps: oUF
## X-Category: UnitFrame
settings.lua
lib.lua
core.lua
layout.lua
Note line 4: Here we define, that oUF (the core addon) is required to run this layout.
The last 4 lines contain our source-files. They will be loaded in the given order.
This file will contain the addons settings. You can view it here
We will have two types of settings:
- Static settings, which define some things we will use throughout the layout, like texture-paths, fonts, stuff like this.
- User-defined settings. These are the settings we want to make accessible to the user in later stages. Note that the values in here will be the default values!
--[ [ SETTINGS
Contains the addons settings
]]
local ADDON_NAME, ns = ...
local settings = {}
-- *********************************************************************************
-- *********************************************************************************
ns.settings = settings
Please focus on line 5: We do want to keep the scope of variables and functions as small as possible. Therefore we will be using the namespace.
Fast and dirty explanation: Every addon has its very own namespace. Function (and variables) can be made accessible in this namespace, but they are not global. With this technique we’re able to split our code over several files without the usage of global function / variables.
The namespace is accessible by the …-argument (vararg).
We do work with a local array settings and inject it into the namespace in line 11.
This file will contain library-functions. I will not define, what will be a library-function and what should belong into the core.lua. You will develop a feeling for this. ;)
This file is pretty straight-forward, but notice how the settings are fetched to make the accessible in this file. You can view it here
This file is pretty straight-forward, too. settings and lib are fetched from the namespace. You can view it here
This file will contain the real creation of the layout. We may call this our main-file and you can view it here
--[ [ LAYOUT
Contains the layout
]]
local ADDON_NAME, ns = ...
-- grab other files from the namespace
local settings = ns.settings
local lib = ns.lib
local core = ns.core
-- Let's get it on!
local Splash = CreateFrame('Frame')
-- *********************************************************************************
Note that I already created a frame in line 13. Frames are really useful, you can do all the magic stuff with them (since the whole UI is based off frames).
We will use this frame for handling some events for us. There is no need to give this frame a name or any size. It will just be used while creating our unitframes.
We have started with the real coding-thing by preparing our addon-files. At this point you should have somethings like this and a media-folder, which already contains your chosen font(s) and textures.
We are now ready to go. Launch World of Warcraft now and make sure to activate oUF and your layout (oUF_Splash in my case). I highly recommend to deactivate any other addon.