Thread Tools Display Modes
05-02-08, 04:21 AM   #1
Oldeface
A Murloc Raider
Join Date: May 2008
Posts: 4
SavedVariable not saving

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_WIDTH0;

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_WIDTHwidth;
    
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.
  Reply With Quote
05-02-08, 10:59 AM   #2
Oldeface
A Murloc Raider
Join Date: May 2008
Posts: 4
Well... I didn't change anything, but when I logged back in today and tested it out... it works.

Not sure if it was a caching problem, or if I had to truly exit the game once before it worked or what, but hurray. XD
  Reply With Quote
05-02-08, 11:23 AM   #3
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
I'm just guessing here but it might be

Code:
PoisonTicker_WIDTH= 0;
if you really want to use XML put
Code:
PoisonTicker_WIDTH = PoisonTicker_WIDTH or 0;
in your OnLoad.

I would also suggest changing SetWidth to a local.

Last edited by Slakah : 05-02-08 at 11:26 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SavedVariable not saving


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off