Earlier Versions
Name | Size | Uploaded | Game Version | Downloads | |
1.0.0 release | 2.52 KB | Feb 22, 2022 | 9.2.0 | 147 | Download |
Description
This library is meant to be used as a dependency for my other addons, and as such it may or may not be directly useful to anyone else.
That said, I will document it anyway in case someone finds value in it for their own addons.
To import the library, make sure that it is set as a dependency in your addon’s .toc file
## Dependencies: stk
In your addon’s main LUA file you will import it via:
— Skag’s Toolkit import
local stk = _G[“STKLIB”] or error(“Cannot find an instance of STKLIB, please download from: https://www.curseforge.com/wow/addons/stk”);
local reqSTKLIBmajor = 01;
local reqSTKLIBminor = 00;
if not stk:stkVersionCheck(reqSTKLIBmajor,reqSTKLIBminor) then
error(“STKLIB is out of date, please download from: https://www.curseforge.com/wow/addons/stk”);
end
Change the reqSTKLIB var values according to which major/minor version of the library you require at a minimum for your addon
In your addon’s primary lua file you can include any or all of these variables which you may have use of.
— Character Vars
local charClass = stk:charClass();
local charGUID = stk:charGUID();
local charLevel = stk:charLevel();
local charMaxLevel = stk:charMaxLevel();
local charName = stk:charName();
local charRace = stk:charRace();
— Region & Server Vars
local currentRegion = stk:currentRegion();
local currentServer = stk:currentServer();
It will be expected that you version your addon with the following variables
local majorVERSION = 02;
local minorVERSION = 00;
local patchVERSION = 00;
local releaseType = “r”; — a = Alpha, b = Beta, = r = Release
In your addon’s primary lua file during the PLAYER_LOGIN or PLAYER_ENTERING_WORLD event you should version check addon against what version (if anything) the user has saved settings from.
if (not SavedVarDB) or
(SavedVarDB.version == nil) or
(SavedVarDB.version.major == nil) or
(SavedVarDB.version.major ~= majorVERSION) then
SavedVarDB = stk:dbInit(majorVERSION,minorVERSION,patchVERSION,releaseType);
end
If this version check fails then stk:dbInit(majorVERSION,minorVERSION,patchVERSION,releaseType) will wipe the Saved Variables and provide you with this basic structure:
SavedVarDB = {
[“options”] = {},
[“version”] = {
[“major”] = ma,
[“minor”] = mi,
[“patch”] = pa,
[“release”] = rel,
},
[“characterData”] = {}
}
You can call stk:firstUpper(“string of text”); to capitalize the first letter of a string, and force all other letters to lowercase. Particularly useful for some instances where Blizzard puts class names or character names in all caps.
local foo = stk:firstUpper(bar);
or
local foo = stk:firstUpper(“HEY GUYS!”);
results in: Hey guys!
If your addon has a UI then you can call stk:savePosition(SavedVarDB,frame); to save the position the user dragged your window to, and you can restore the position of the frame when showing it with stk:setPosition(SavedVarDB,frame);
Addons which use this library include:
Allowance
Alt Tracker
Shut Yo Chat
Zandalari Money Pieces
Add a comment