You don't need global names at all... just iterate over oUF's internal list of frames:
Code:
for _, frame in next, oUF.objects do
frame:SetAlpha(0.5)
end
Also,
InCombatLockdown() is always false inside the PLAYER_REGEN_DISABLED event, since the purpose (or one of the purposes) of that event is to notify addons that combat is beginning so they can make changes for combat. Lockdown doesn't take effect until the event is finished being handled. Use
UnitAffectingCombat("player") instead.
Also also, there's really no need to factor that out into multiple independent functions when there is only one chain of execution. Function calls are slow. Avoid them whenever posisble.
Code:
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("PLAYER_REGEN_DISABLED")
f:RegisterEvent("PLAYER_REGEN_ENABLED")
f:SetScript("OnEvent", function()
local a = UnitAffectingCombat("player") and 1 or 0.5
for _, frame in next, oUF.objects do
frame:SetAlpha(a)
end
end)