View Single Post
12-17-18, 12:28 AM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
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:
  1. function sActionbars_OnEvent(self, event, ...)
  2.     sActionbars:SetDefaultOptions()
  3.  
  4.     local hotkeyAlpha = sActionbarsDB.showHotKeys and 1 or 0
  5.     local macroAlpha = sActionbarsDB.showMacronames and 1 or 0
  6.  
  7.     for i = 1, 12 do
  8.             _G["ActionButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- main bar
  9.             _G["ActionButton"..i.."Name"]:SetAlpha(macroAlpha) -- main bar
  10.             _G["MultiBarBottomRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom right bar
  11.             _G["MultiBarBottomRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom right bar
  12.             _G["MultiBarBottomLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom left bar
  13.             _G["MultiBarBottomLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom left bar
  14.             _G["MultiBarRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- right bar
  15.             _G["MultiBarRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- right bar
  16.             _G["MultiBarLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- left bar
  17.             _G["MultiBarLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- left bar
  18.     end
  19. end
  20.  
  21. function sActionbars_OnLoad(self)
  22.     self:RegisterEvent("PLAYER_LOGIN")
  23. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-17-18 at 02:45 AM.
  Reply With Quote