Lua Code:
local frame = CreateFrame("Frame", "Bob", UIParent)
frame:SetPoint("CENTER",UIParent,0,0)
frame:SetSize(100,100)
You can just use self, since a frame to hook into isn't needed, oUF handles all that.
Lua Code:
-- Register it with oUF
self.Health = Health
The Self.Health is a reference to self.Health from oUF itself, in that part you're telling oUF that the frame you called Health is self.Health from oUF. Otherwise oUF doesn't know what to do with it.
And this should purely work...
Lua Code:
------------------------------------------------------------------------
-- oUF Layout boiletplate
-- Author : Kelly Crabbé
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Namespace
------------------------------------------------------------------------
local _, ns = ...
------------------------------------------------------------------------
-- Config
------------------------------------------------------------------------
local NORMALFONT = STANDARD_TEXT_FONT
local TEXTURE = [=[Interface\ChatFrame\ChatFrameBackground]=]
local BACKDROP = {
bgFile = TEXTURE, insets = {top = -1, bottom = -1, left = -1, right = -1}
}
-----------------------------
-- Add custom functions (overrides)
------------------------------------------------------------------------
-- UnitSpecific settings
------------------------------------------------------------------------
local UnitSpecific = {
player = function(self)
-- player specific stuff
end,
target = function(self)
-- target specific stuff
end,
party = function(self)
-- party frames
end,
boss = function(self)
-- boss frames
end,
arena = function(self)
-- arena frames
end
}
UnitSpecific.raid = UnitSpecific.party -- raid is equal to party
------------------------------------------------------------------------
-- Shared settings
------------------------------------------------------------------------
local function Shared(self, unit)
self:SetScript("OnEnter", UnitFrame_OnEnter)
self:SetScript("OnLeave", UnitFrame_OnLeave)
self:RegisterForClicks"AnyUp"
-- shared functions
-----------------------------
-- Health
-- Your Health Statusbar
local Health = CreateFrame("StatusBar", nil, self)
Health:SetHeight(50)
Health:SetStatusBarTexture(TEXTURE)
Health:SetPoint('TOP')
Health:SetPoint('LEFT')
Health:SetPoint('RIGHT')
-- Your health background, not needed but handy to see
local Healthbg = Health:CreateTexture(nil, 'BACKGROUND')
Healthbg:SetAllPoints(Health)
Healthbg:SetTexture(TEXTURE)
Healthbg:SetVertexColor(139/255, 70/255, 70/255)
Healthbg.multiplier = .75
-- Options
Health.frequentUpdates = true
Health.colorTapping = true
Health.colorDisconnected = true
Health.colorClass = true
Health.colorReaction = true
Health.colorHealth = true
-- Register it with oUF
self.Health = Health
self.Health.bg = Healthbg
-----------------------------
-- Power
-- Your Power Statusbar
local Power = CreateFrame("StatusBar", nil, self)
Power:SetHeight(50)
Power:SetStatusBarTexture(TEXTURE)
Power:SetPoint('TOP')
Power:SetPoint('LEFT')
Power:SetPoint('RIGHT')
-- Your Power background, not needed but handy to see
local Powerbg = Power:CreateTexture(nil, 'BACKGROUND')
Powerbg:SetAllPoints(Power)
Powerbg:SetTexture(TEXTURE)
Powerbg:SetVertexColor(139/255, 70/255, 70/255)
Powerbg.multiplier = .75
-- Options
Power.frequentUpdates = true
Power.colorPower = true -- powertype colored bar
Power.colorClassNPC = true -- color power based on NPC
Power.colorClassPet = true -- color power based on pet type
-- Register it with oUF
self.Power = Power
self.Power.bg = Powerbg
-- leave this in!!
if(UnitSpecific[unit]) then
return UnitSpecific[unit](self)
end
end
oUF:RegisterStyle('Bob', Shared)
oUF:Factory(function(self)
self:SetActiveStyle('Bob')
self:Spawn('player'):SetPoint('CENTER', -300, -250)
self:Spawn('target'):SetPoint('CENTER', 300, -250)
end)