Okay, so I'm writing my first addon - thought I'd start simple, since I'm learning pretty much everything as I go.
All it will do is pop up a frame when a new version of that addon is installed. I made my frame in WoWUIDesigner, wrote out my lua page, and thought I'd store the version number in saved variables. Then, if the new version number is > than the saved version number, the frame would pop up with the major changes in my UI comp - things that users might need to do, like reset databases, etc. Because, let's face it, not everyone reads changelogs.
(There would be an option to disable, of course.)
So... I found
this function on WoWWiki - GetAddOnMetadata("addon", "field"), but I'm having difficulties in putting it into practice. Any help would be greatly appreciated.
Here is my lua:
Code:
--variables
SSWELCOME_LASTVERSION = 0
SSWELCOME_VERSION = 0;
function SSWelcome_OnLoad(self)
self:RegisterEvent("ADDON_LOADED");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
end
function SSWelcome_OnEvent(self, event, ...)
if ( event == "ADDON_LOADED" ) then
local addon = select(1, ...);
if ( addon == "SSWelcome" ) then
DEFAULT_CHAT_FRAME:AddMessage("Welcome to Seerah's Suitcase!");
end
return;
end
--current version?
if ( event == "PLAYER_ENTERING_WORLD" ) then
SSWELCOME_VERSION = GetAddOnMetadata("SSWelcome", "Version");
return;
end
--updated?
local version = GetAddOnMetadata("SSWelcome", "Version");
if ( version > SSWELCOME_LASTVERSION ) then
self.frame:Show()
else self.frame:Hide()
end
--update sv
SSWELCOME_LASTVERSION = version
end
and this is what gets put into my saved variables file....