So im trying to load and use the saved varables for my addon.
Here is the current lua code:
Code:
local addon, sActionbars = ...
SlashCmdList['RELOADUI'] = function()
ReloadUI()
end
SLASH_RELOADUI1 = '/rl'
function sActionbars:RegisterDefaultSetting(key, value)
if ( sActionbarsDB == nil ) then
sActionbarsDB = {}
end
if ( sActionbarsDB[key] == nil ) then
sActionbarsDB[key] = value
end
end
function sActionbars:SetDefaultOptions()
sActionbars:RegisterDefaultSetting("showHotKeys", false)
sActionbars:RegisterDefaultSetting("showMacronames", false)
end
function sActionbars_OnLoad(self)
self:RegisterEvent("ADDON_LOADED")
end
function sActionbars_OnEvent(self, event, ...)
if ( event == "ADDON_LOADED" ) then
local name = ...
if ( name == "sActionbars" ) then
sActionbars:SetDefaultOptions()
self:UnregisterEvent("ADDON_LOADED")
end
end
end
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["MultiBarBottomRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom right bar
_G["MultiBarBottomLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom left bar
_G["MultiBarRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- right bar
_G["MultiBarLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- left bar
end
for i = 1, 12 do
_G["ActionButton"..i.."Name"]:SetAlpha(macroAlpha) -- main bar
_G["MultiBarBottomRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom right bar
_G["MultiBarBottomLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom left bar
_G["MultiBarRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- right bar
_G["MultiBarLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- left bar
end
local function UpdateRange( self, elapsed )
local rangeTimer = self.rangeTimer
local icon = self.icon;
if( rangeTimer == TOOLTIP_UPDATE_TIME ) then
local inRange = IsActionInRange( self.action );
if( inRange == false ) then
-- Red Out Button
icon:SetVertexColor( 1, 0, 0 );
else
local canUse, amountMana = IsUsableAction( self.action );
if( canUse ) then
icon:SetVertexColor( 1.0, 1.0, 1.0 );
elseif( amountMana ) then
icon:SetVertexColor( 0.5, 0.5, 1.0 );
else
icon:SetVertexColor( 0.4, 0.4, 0.4 );
end
end
end
end
do
hooksecurefunc( "ActionButton_OnUpdate", UpdateRange );
end
Here is the xml file that loads before the lua file:
Code:
<Ui xmlns="http:\\www.blizzard.com\wow\ui\" xmlns:xsi="http:\\www.w3.org\2001\XMLSchema-instance" xsi:schemaLocation="http:\\www.blizzard.com\wow\ui\ ..\FrameXML\UI.xsd">
<Script file="sActionbars.lua"/>
<Frame name="sActionbars">
<Scripts>
<OnLoad function="sActionbars_OnLoad" />
<OnEvent function="sActionbars_OnEvent" />
</Scripts>
</Frame>
</Ui>
But when i log into WoW it thows me this error:
Code:
1x sActionbars\sActionbars-8.1.0.lua:36: attempt to index global 'sActionbarsDB' (a nil value)
sActionbars\sActionbars-8.1.0.lua:36: in main chunk
Locals:
addon = "sActionbars"
sActionbars = <table> {
SetDefaultOptions = <function> defined @sActionbars\sActionbars.lua:17
RegisterDefaultSetting = <function> defined @sActionbars\sActionbars.lua:8
}
(*temporary) = nil
(*temporary) = <function> defined @sActionbars\sActionbars.lua:3
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to index global 'sActionbarsDB' (a nil value)"
What am I doing wrong here?
Thanks
Coke