Which code is written in a more correct way or are they both the same?
Style A:
Lua Code:
local cBuffs = CreateFrame("Frame")
cBuffs:RegisterEvent("ADDON_LOADED")
cBuffs:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == "cBuffs" then
BuffFrame:SetScale(1.193)
local origSecondsToTimeAbbrev = _G.SecondsToTimeAbbrev
local function SecondsToTimeAbbrevHook(seconds)
origSecondsToTimeAbbrev(seconds)
local tempTime
if (seconds >= 86400) then
tempTime = ceil(seconds / 86400)
return '|cffffffff%dd|r', tempTime
end
if (seconds >= 3600) then
tempTime = ceil(seconds / 3600)
return '|cffffffff%dh|r', tempTime
end
if (seconds >= 60) then
tempTime = ceil(seconds / 60)
return '|cffffffff%dm|r', tempTime
end
return '|cffffffff%d|r', seconds
end
SecondsToTimeAbbrev = SecondsToTimeAbbrevHook
hooksecurefunc('AuraButton_Update', function(self, index)
local font = [[Fonts\ARIALN.ttf]]
local button = _G[self..index]
if (button) then
local duration = _G[self..index..'Duration']
if (duration) then
duration:ClearAllPoints()
duration:SetPoint('BOTTOM', button, 'BOTTOM', 0, -2)
if (self:match('Debuff')) then
duration:SetFont(font, 12, 'THINOUTLINE')
else
duration:SetFont(font, 12, 'THINOUTLINE')
end
duration:SetShadowOffset(0, 0)
duration:SetDrawLayer('OVERLAY')
end
local count = _G[self..index..'Count']
if (count) then
count:ClearAllPoints()
count:SetPoint('TOPRIGHT', button)
if (self:match('Debuff')) then
count:SetFont(font, 12, 'THINOUTLINE')
else
count:SetFont(font, 12, 'THINOUTLINE')
end
count:SetShadowOffset(0, 0)
count:SetDrawLayer('OVERLAY')
end
end
end)
end
SlashCmdList['RELOADUI'] = function()
ReloadUI()
end
SLASH_RELOADUI1 = '/rl'
self:UnregisterEvent("ADDON_LOADED")
end)
Style B:
Lua Code:
local cBuffs = CreateFrame("Frame")
cBuffs:RegisterEvent("ADDON_LOADED")
cBuffs:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == "cBuffs" then
self:SetScale()
self:TimeDisplayAdjust()
self:Duration_Count_Placement()
end
SlashCmdList['RELOADUI'] = function()
ReloadUI()
end
SLASH_RELOADUI1 = '/rl'
self:UnregisterEvent("ADDON_LOADED")
end)
function cBuffs:SetScale()
BuffFrame:SetScale(1.193)
end
function cBuffs:TimeDisplayAdjust()
local origSecondsToTimeAbbrev = _G.SecondsToTimeAbbrev
local function SecondsToTimeAbbrevHook(seconds)
origSecondsToTimeAbbrev(seconds)
local tempTime
if (seconds >= 86400) then
tempTime = ceil(seconds / 86400)
return '|cffffffff%dd|r', tempTime
end
if (seconds >= 3600) then
tempTime = ceil(seconds / 3600)
return '|cffffffff%dh|r', tempTime
end
if (seconds >= 60) then
tempTime = ceil(seconds / 60)
return '|cffffffff%dm|r', tempTime
end
return '|cffffffff%d|r', seconds
end
SecondsToTimeAbbrev = SecondsToTimeAbbrevHook
end
function cBuffs:Duration_Count_Placement()
hooksecurefunc('AuraButton_Update', function(self, index)
local font = [[Fonts\ARIALN.ttf]]
local button = _G[self..index]
if (button) then
local duration = _G[self..index..'Duration']
if (duration) then
duration:ClearAllPoints()
duration:SetPoint('BOTTOM', button, 'BOTTOM', 0, -2)
if (self:match('Debuff')) then
duration:SetFont(font, 12, 'THINOUTLINE')
else
duration:SetFont(font, 12, 'THINOUTLINE')
end
duration:SetShadowOffset(0, 0)
duration:SetDrawLayer('OVERLAY')
end
local count = _G[self..index..'Count']
if (count) then
count:ClearAllPoints()
count:SetPoint('TOPRIGHT', button)
if (self:match('Debuff')) then
count:SetFont(font, 12, 'THINOUTLINE')
else
count:SetFont(font, 12, 'THINOUTLINE')
end
count:SetShadowOffset(0, 0)
count:SetDrawLayer('OVERLAY')
end
end
end)
end
Thanks for any opinion on this.
Coke