You're executing
Code:
local hotkeyAlpha = sActionbarsDB.showHotKeys and 1 or 0
As the file loads (as well as all the for i = 1, 12 do setup code) and
Code:
if ( sActionbarsDB == nil ) then
sActionbarsDB = {}
end
after the file has loaded, created the frame, registered for, and recieved the event.
You could create
local hotkeyAlpha as a nil variable at the top of the file and then initialise it after testing for the SV in the event but then you woulld still have to move the setup code into the event as well.
If you move all the ADDON_LOADED code into PLAYER_LOGIN and do everything there then you only have one event to worry about (no name test or unregister required as it only fires once after all ADDON_LOADED events and before PLAYER_ENTERING_WORLD) and you know that, by then, the game has loaded your SavedVariables, if they exist yet.
Lua Code:
function sActionbars_OnEvent(self, event, ...)
sActionbars:SetDefaultOptions()
local hotkeyAlpha = sActionbarsDB.showHotKeys and 1 or 0
local macroAlpha = sActionbarsDB.showMacronames and 1 or 0
for i = 1, 12 do
_G["ActionButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- main bar
_G["ActionButton"..i.."Name"]:SetAlpha(macroAlpha) -- main bar
_G["MultiBarBottomRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom right bar
_G["MultiBarBottomRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom right bar
_G["MultiBarBottomLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom left bar
_G["MultiBarBottomLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom left bar
_G["MultiBarRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- right bar
_G["MultiBarRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- right bar
_G["MultiBarLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- left bar
_G["MultiBarLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- left bar
end
end
function sActionbars_OnLoad(self)
self:RegisterEvent("PLAYER_LOGIN")
end