So, I have looked all around the internet and read all about Saved Variables, but for some reason I can't get it to work no matter what-- I must be doing something very obviously wrong that is getting past me!
Essentially I have a working addon that I am trying to make the width settable.
TOC:
PHP Code:
## Interface: 20400
## Title: PoisonTicker
## Version: 0.8
## Notes: Displays when your Deadly Poison will Proc, and how many procs are on the target.
## Author: Oldeface
## SavedVariablesPerCharacter: PoisonTicker_WIDTH
PoisonTicker.lua
PoisonTicker.xml
LUA basics:
PHP Code:
PoisonTicker_WIDTH= 0;
function PoisonTicker_OnLoad(self)
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
self:RegisterEvent("PLAYER_REGEN_DISABLED");
self:RegisterEvent("PLAYER_REGEN_ENABLED");
self:RegisterEvent("ADDON_LOADED");
ChatFrame1:AddMessage("Loaded");
SlashCmdList["POISONTICKER"] = SetWidth;
SLASH_POISONTICKER1 = "/poisonticker";
SLASH_POISONTICKER2 = "/pt";
end
function PoisonTicker_OnEvent(event)
if(event == "ADDON_LOADED" and arg1=="PoisonTicker") then
PoisonTicker_PoisonBar:SetWidth(PoisonTicker_WIDTH);
PoisonTicker_BG:SetWidth(PoisonTicker_WIDTH);
end
...
end
...
function SetWidth(width)
PoisonTicker_WIDTH= width;
PoisonTicker_PoisonBar:SetWidth(PoisonTicker_WIDTH);
PoisonTicker_BG:SetWidth(PoisonTicker_WIDTH);
end
This resizes the bar and BG to the proper proportions, but whenever I ReloadUI PoisonTicker_WIDTH is set back to 0!
Any help would be much appreciated.