So I have two modules, api.lua and core.lua, and here's what they look like.
api.lua:
Lua Code:
local E, D, U, B = unpack(select(2, ...));
local G, A, C = unpack(U);
local BACKDROP = LSM:Fetch("background", "backdrop");
A.InitFrame = function(f, unit)
f:RegisterForClicks("anyup");
f:SetScript("OnEnter", UnitFrame_OnEnter);
f:SetScript("OnLeave", UnitFrame_OnLeave);
f:SetFrameStrata("LOW");
f:SetBackdrop({
bgFile = BACKDROP,
tile = true,
tileSize = 16,
});
f:SetBackdropColor(0.1, 0.1, 0.1, 1);
f:SetSize(G[unit]["width"], G[unit]["height"]);
A.GenPosition(f, unit);
end
A.RegEvent = function(f, ...)
for i = 1, select("#", ...) do
f:RegisterEvent(select(i, ...));
end
end
so on..........
core.lua:
Lua Code:
local E, D, U, B = unpack(select(2, ...));
local G, A, C = unpack(U);
C.stylemanager = function(f, unit)
if C.styles[unit] then
C.styles[unit](f, unit);
end
end
YUF:RegisterStyle("YUF_Style", C.stylemanager);
YUF:Spawn("player", "YUI_PlayerFrame");
YUF:Spawn("target", "YUI_TargetFrame");
Inside "A.InitFrame" function I was trying to register event if the unit is "player" by using "A.RegEvent" which would look like:
Lua Code:
if (unit == "player") then
A.RegEvent(f, "PLAYER_REGEN_DISABLED", "PLAYER_REGEN_ENABLED");
f:SetScript("OnEvent", function(self, event, ...)
if (event == "PLAYER_REGEN_DISABLED") then
if UnitAffectingCombat(unit) then
f:SetBackdropColor(1, 0, 0, 1);
end
else
f:SetBackdropColor(0.1, 0.1, 0.1, 1);
end
end);
else
f:SetBackdropColor(0.1, 0.1, 0.1, 1);
end
But, oUF printed the following errors which I don't really get with:
Could anyone please tell me what is going wrong with my code?
Thank you.
EDIT: The reason that I'm doing this is to change background color to red when the player is in combat.
If there is any better ways to do so, please let me know