The API documentation from ouf Swing:
Code:
--[[
Elements handled:
.Swing [frame]
.Swing.Text [fontstring]
.Swing.TextMH [fontstring]
.Swing.TextOH [fontstring]
Code Example:
.Swing = CreateFrame("Frame", nil, self)
.Swing:SetWidth(400)
.Swing:SetHeight(20)
.Swing:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, 100)
.Swing.texture = [=[Interface\TargetingFrame\UI-StatusBar]=]
.Swing.color = {1, 0, 0, 0.8}
.Swing.textureBG = [=[Interface\TargetingFrame\UI-StatusBar]=]
.Swing.colorBG = {0, 0, 0, 0.8}
Autocreated if not created by Layout:
- .Twohand [statusbar]
- .Mainhand [statusbar]
- .Offhand [statusbar]
Shared:
- disableMelee [boolean]
- disableRanged [boolean]
- hideOoc [boolean] (Autohide on leaving Combat)
Functions that can be overridden from within a layout:
- .OverrideText(text, now)
--]]
Try something like below - (Not tested!)
Code:
if(IsAddOnLoaded("oUF_Swing")) then
self.Swing = CreateFrame("Frame", nil, self)
self.Swing:SetPoint("CENTE", "UIParent", "CENTER", 0, 200)
self.Swing:SetHeigh(20)
self.Swing:SetWidth(200)
self.Swing:SetStatusBarTexture(cfg.statusbar_texture)
self.Swing:GetStatusBarTexture():SetHorizTile(false)
self.Swing:SetStatusBarColor(0.3, 0.5, 0.2)
self.Swing.disableMelee = false
self.Swing.DisableRanged = false
self.Swing.hideOoc = true
end
As Rostok pointed out, LUA is case sensitive so you do need to be careful of your capitalisations.
Also this:
, would be incorrect with your code for a couple of reasons.
- "self.swing" is the incorrect capitalisation of the ouf element. The correct version is self.Swing. As you had it throughout your code might throw errors and wouldn't work as expected.
- The 'swing' after your equals is a nil global. You haven't defined it anywhere(that I can see in the code you've provided).
- That line is unnecessary. When you do this:
Code:
self.Swing = CreateFrame("Frame", nil, self)
you are creating the frame and assigning it directly to the ouf Swing element.
If you had written the code like this:
Code:
local s = CreateFrame("Frame", nil, self)
s:SetWidth(400)
s:SetHeight(20)
s:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, 200)
-- etc, etc
then you would require the self.Swing = s, because you've created the frame, manipulated it, and then are handing it off to the ouf Swing element.
I hope that works and hasn't confused you further.