WoWInterface SVN LibSpellName2SID

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 152 to Rev 151
    Reverse comparison

Rev 152 → Rev 151

trunk/LibSpellName2SID-1.1/LibSpellName2SID-1.1/LibSpellName2SID-1.1.lua
3,7 → 3,7
-- V.10000: 2009 originally by Twobits[1], as part of ReadySpells[2]
-- 2010 edited by benots4[3]
-- 2017 published as an addon of its own by aallkkaa[4]
-- V.10001 - 10103: 2017-2019 WoW 7.3.x to 8.x versions by aallkkaa [4]
-- V.10001 - 10102: 2017-2019 WoW 7.3.x to 8.0.1 versions by aallkkaa [4]
--
-- [1] https://www.wowinterface.com/forums/member.php?userid=139157
-- https://www.curseforge.com/members/twobits
38,7 → 38,7
 
-- Library's version values --
local LibSpellName2SID_MAJOR = "LibSpellName2SID-1.1";
local LibSpellName2SID_MINOR = 10103;
local LibSpellName2SID_MINOR = 10102;
 
-- DataSource --
-- gameBuild = 29981
923,9 → 923,6
["Survival of the Fittest"] = 264735,
["Growl"] = 2649,
},
["Blood Beast"] = {
["Blood Bolt"] = 288962,
},
},
["Survival"] = {
["Harpoon"] = 190925,
trunk/LibSpellName2SID-1.1/LibSpellName2SID-1.1.toc
1,7 → 1,7
## Interface: 80105
## Title: Lib: SpellName2SID-1.1
## Notes: Table of English Spell Names and corresponding Spell IDs
## Version: 1.1.03
## Version: 1.1.02
## LoadOnDemand: 1
## Author: aallkkaa
## X-Original-Author: twobits
populator/trunk/LibSpellName2SID-1.1-Populator/LibSpellName2SID-1.1-Populator.lua
8,12 → 8,9
----------
local AddonName, AddonEnv = ...;
 
-- Local copies of the saved variables' tables: SpellNamesAndIDs, SpellNamesAndIDs_PASSIVES and DEBUG_messages
local SN2SID_table, SN2SID_PASSIVES_table, DEBUGmsgs;
-- Local copies of the saved variables' tables: SpellNamesAndIDs and SpellNamesAndIDs_PASSIVES
local SN2SID_table, SN2SID_PASSIVES_table;
 
-- Variables for debugging
local DBG_CurrentEvent = "" -- Event last fired when a task is being done
 
-- WoW Expansion/Patch constants
local NumberOfTalentTiers = 7; -- Current number of talent tiers - WoW-7.x.y and 8.x.y
-- local NumberOfPVPTalentTiers = 6; -- Current number of PVP talent tiers - WoW-7.x.y
197,23 → 194,6
},
},
["HUNTER"] = {
-- TODO: SPECS --
["Beast Mastery"] = {
["Call Pet"] = 9,
["Pet Utility"] = 103,
},
["Marksmanship"] = {
["Call Pet"] = 9,
["Pet Utility"] = 103,
},
["Survival"] = {
["Call Pet"] = 9,
["Pet Utility"] = 103,
},
["FlyoutsTOGET"] = {
["Call Pet"] = 9,
["Pet Utility"] = 103,
},
["Pets"] = {
-- https://www.wowhead.com/battle-for-azeroth-hunter-pet-guide#hunter-pet-family-list-tenacity
["Ferocity"] = {
271,9 → 251,6
["Talon Rend"] = 263852,
["Trick"] = 94022,
},
["Blood Beast"] = { -- 8.1
["Blood Bolt"] = 288962,
},
["Boar"] = { -- 8.x
["Bristle"] = 263869,
},
443,18 → 420,6
},
},
["MAGE"] = {
["Arcane"] = {
["Polymorph Variants"] = 92,
},
["Fire"] = {
["Polymorph Variants"] = 92,
},
["Frost"] = {
["Polymorph Variants"] = 92,
},
["FlyoutsTOGET"] = {
["Polymorph Variants"] = 92,
},
["Flyouts"] = {
-- Polymorph Variants are now fetchable (all the ones currently ingame) from the game,
-- regardless of whether the Mage has them or not (all, some, one or even none).
569,31 → 534,16
["Teleport: Dazar'alor"] = 281404, -- Horde only
},
},
-- Get the Pets spell from a high level Frost Mage instead
--[[
["Pets"] = {
["Water Elemental"] = { -- Frost specialization only
["Freeze"] = 33395,
["Waterbolt"] = 31707,
},
},
]]--
},
-- All Rogue Poisons are fetchable from the logged in character. The bellow is no longer needed.
--[[
["ROGUE"] = {
["Assassination"] = {
["Poisons"] = 66,
},
["Subtlety"] = {
["Poisons"] = 66,
},
["Outlaw"] = {
["Poisons"] = 66,
},
["FlyoutsTOGET"] = {
["Poisons"] = 66,
},
--[[
["Flyouts"] = {
["Poisons"] = { -- Since WoW 7.0, (I think) Assassintation specialization only. But, at
-- least on WoW 8.1.5, on the SpellBook of all three specializations.
604,23 → 554,20
["Wound Poison"] = 8679,
},
},
]]--
},
]]--
["SHAMAN"] = {
["Elemental"] = {
["Bloodlust"] = 2825, -- Horde
["Heroism"] = 32182, -- Alliance
["Hex Variants"] = 106,
},
["Enhancement"] = {
["Bloodlust"] = 2825, -- Horde
["Heroism"] = 32182, -- Alliance
["Hex Variants"] = 106,
},
["Restoration"] = {
["Bloodlust"] = 2825, -- Horde
["Heroism"] = 32182, -- Alliance
["Hex Variants"] = 106,
},
-- Hex Variants are now fetchable (all the ones currently ingame) from the game,
-- regardless of whether the Shaman has them or not (all, some, one or even none).
644,9 → 591,6
-- TODO: Implement a way to fetch the Shaman Hex Variants (as well as the Mage Polymorph
-- Variants), even if the character does not know any, by using the logic above (and
-- bellow if needed).
["FlyoutsTOGET"] = {
["Hex Variants"] = 106,
},
--[[
["Flyouts"] = {
["Hex Variants"] = { -- Hex variants (including the default "Frog") are all
676,14 → 620,14
},
]]--
["Pets"] = { -- In WoW 7.x.y, only the Elemental specialization has pets, which are only
-- controllable if the talent "Primal Elementalist"(5,2) is active (they're
-- guardians (no spells castable by the player) otherwise). On top of that,
-- although the Earth Elemental is always available to the Elemental Shaman
-- , the Fire and Storm elementals are mutually exclusive (Fire Elemental
-- becomes Storm Elemental if the talent "Storm Elemental" is chosen).
-- TL;DR: Better make sure the spells bellow are added, rather than going
-- through the gimmick of swithcing the talents every time we update the
-- SHAMAN lists of spells.
-- controllable if the talent "Primal Elementalist"(5,2) is active (they're
-- guardians (no spells castable by the player) otherwise). On top of that,
-- although the Earth Elemental is always available to the Elemental Shaman
-- , the Fire and Storm elementals are mutually exclusive (Fire Elemental
-- becomes Storm Elemental if the talent "Storm Elemental" is chosen).
-- TL;DR: Better make sure the spells bellow are added, rather than going
-- through the gimmick of swithcing the talents every time we update the
-- SHAMAN lists of spells.
["Earth Elemental"] = {
["Angered Earth"] = 36213, -- Taunt
["Harden Skin"] = 118337, -- -40% damage taken by the Shaman
702,18 → 646,6
},
},
["WARLOCK"] = {
["Affliction"] = {
["Summon Demon"] = 10,
},
["Demonology"] = {
["Summon Demon"] = 10,
},
["Destruction"] = {
["Summon Demon"] = 10,
},
["FlyoutsTOGET"] = {
["Summon Demon"] = 10,
},
["Pets"] = { -- Spells of the glyph-enhanced versions of the regular Warlock Demons.
-- NB: We're including spells that remain the same on both versions of the
-- demon.
860,15 → 792,14
----------------------------------------------------------------------------------------------------
 
-- Update the General tab dataSource + raceBuilds --
-- local updateGeneralTabMetadata_func = function(SN2SID_table, SN2SID_PASSIVES_table, curLocale, gameBuild, universalRaceName, generalTabName, charLevel)
-- local updateGeneralTabMetadata_func = function(curLocale, gameBuild, universalRaceName, generalTabName, charLevel)
-- local updateGeneralTabMetadata_func = function(curLocale, gameBuild, universalRaceName, charLevel)
local updateGeneralTabMetadata_func = function(curLocale, gameBuild, charLevel)
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateGeneralTabMetadata_func: START");
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": Check whether GeneralTab\'s Metadata needs update");
if not updateGeneralTabMetadata then
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": GeneralTab\'s Metadata does NOT need update.");
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateGeneralTabMetadata_func: END");
return;
end
tinsert(DEBUGmsgs[DBG_CurrentEvent], "GeneralTab\'s Metadata DOES need update.");
 
-- print(AddonName.. ": Will now check whether the GeneralTab Metadata needs updating.");
-- Actively-cast spells
if charLevel > SN2SID_table[generalTabName].METADATA.dataSource.charLevel then
911,19 → 842,15
updateGeneralSpells = true;
end
updateGeneralTabMetadata = false;
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateGeneralTabMetadata_func: END");
end
 
-- Update the Class dataSource --
-- local updateClassMetadata_func = function(SN2SID_table, SN2SID_PASSIVES_table, curLocale, gameBuild, universalClassName, charLevel)
-- local updateClassMetadata_func = function(curLocale, gameBuild, universalClassName, charLevel)
local updateClassMetadata_func = function(curLocale, gameBuild, charLevel)
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateClassMetadata_func: START");
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": Check whether ".. universalClassName.. "\'s Metadata needs update.");
if not updateClassMetadata then
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": ".. universalClassName.. "\'s Metadata does NOT need update.");
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateClassMetadata_func: END");
return;
end
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": ".. universalClassName.. "\'s Metadata DOES need update.");
-- print(AddonName.. ": Will now check whether the ".. universalClassName.. " Metadata needs updating.");
-- Actively-cast spells
if charLevel > SN2SID_table[universalClassName].METADATA.dataSource.charLevel then
952,16 → 879,16
updateClassSpells = true;
end
updateClassMetadata = false;
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateClassMetadata_func: END");
end
 
 
---- Functions to update the lists of Spell Names and their IDs ----
--------------------------------------------------------------------
 
-- Update the PvE Talents' lists of spells
-- Update the Talents' lists of spells
-- local updateTalentSpells_func = function(SN2SID_table, SN2SID_PASSIVES_table, universalClassName, ClassNumSpecs, ClassSpecNames2IDs)
-- local updateTalentSpells_func = function(universalClassName, ClassNumSpecs, ClassSpecNames2IDs)
local updateTalentSpells_func = function(ClassNumSpecs, ClassSpecNames2IDs)
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateTalentSpells_func: START");
if not updateClassSpells then -- Sanity check
return;
end
980,7 → 907,7
-- SN2SID_PASSIVES_table[universalClassName][locSpecName.."_Talents"] = {};
-- end
else
-- print(AddonName.. ": PVE: NO specialization has been selected for this character!");
print(AddonName.. ": PVE: NO specialization has been selected for this character!");
return;
end
-- Populate the "SpecName_Talents" subtables
1010,17 → 937,16
-- and then fetch the keys in order from that array-table and then the corresponding values
-- from another tab le (the original, unordered/unsorted key-value pairs table).
-- The function from https://wow.gamepedia.com/Orderedpairs gets you the ordered values
-- from the unordered table in running-time, but cannot be used to change the stored data,
-- form the unordered table in running-time, but cannot be used to change the stored data,
-- just like the extract-keys-then-sort-them method above.
-- Thus, it's not possible to store the data in an easy to visually (or OS-based) diff two
-- versions of a database, as I wished.
end
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateTalentSpells_func: END");
end
 
-- Update the PvP Talents' lists of spells
-- local updatePVPTalentSpells_func = function(SN2SID_table, SN2SID_PASSIVES_table, universalClassName, ClassNumSpecs, ClassSpecNames2IDs)
-- local updatePVPTalentSpells_func = function(universalClassName, ClassNumSpecs, ClassSpecNames2IDs)
local updatePVPTalentSpells_func = function(ClassNumSpecs, ClassSpecNames2IDs)
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updatePVPTalentSpells_func: START");
if not updateClassSpells then -- Sanity check
return;
end
1039,7 → 965,7
SN2SID_PASSIVES_table[universalClassName][locSpecName.."_PVPTalents"] = {};
end
else
-- print(AddonName.. ": PVP: NO specialization has been selected for this character!");
print(AddonName.. ": PVP: NO specialization has been selected for this character!");
return;
end
-- Populate the "SpecName_PVPTalents" subtables
1060,13 → 986,11
end
end
end
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updatePVPTalentSpells_func: END");
end
 
local armorSkills, weaponSkills;
-- Helper functions to function updateSpellbookSpells_func() --
local addSpellbookSpellToGeneral_func = function(spellName, spellSubName, spellID)
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addSpellbookSpellToGeneral_func: START");
-- Store Passive and Active abilities into their own separate tables
if IsPassiveSpell(spellID) then
if spellName == "Armor Skills" then
1110,7 → 1034,7
-- in our list of hardcoded Zone spells first. Now, we do that test last, as there is at
-- least one instance of a spell with the same name, but different IDs, that is a Racial
-- (that we fetch from the server) and also a hardcoded Zone ability: "Light's Judgment".
if spellSubName and strfind(spellSubName, "Racial") then
if spellSubName and strfind(spellSubName, "Racial") then
if not SN2SID_table[generalTabName].Racials[universalRaceName] then
SN2SID_table[generalTabName].Racials[universalRaceName] = { [spellName] = spellID };
else
1123,131 → 1047,36
SN2SID_table[generalTabName].GuildPerks[spellName] = spellID;
end
-- Will now test for the hardcoded ZoneAbilities, to place them in the correct subcategory
elseif postUpdate_Spells2Add.General.ZoneAbilities[spellName] then
if not SN2SID_table[generalTabName].ZoneAbilities then
SN2SID_table[generalTabName].ZoneAbilities = { [spellName] = spellID };
else
SN2SID_table[generalTabName].ZoneAbilities[spellName] = spellID;
end
elseif postUpdate_Spells2Add.General.ZoneAbilities[spellName] then
if not SN2SID_table[generalTabName].ZoneAbilities then
SN2SID_table[generalTabName].ZoneAbilities = { [spellName] = spellID };
else
SN2SID_table[generalTabName].ZoneAbilities[spellName] = spellID;
end
-- All other spells go into the "Others" subcategory
elseif not SN2SID_table[generalTabName].Others then
elseif not SN2SID_table[generalTabName].Others then
SN2SID_table[generalTabName].Others = { [spellName] = spellID };
else
SN2SID_table[generalTabName].Others[spellName] = spellID;
end
end
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addSpellbookSpellToGeneral_func: END");
end
 
local addPolymorphOrHexFlyoutSpell_func = function(flyoutButton, flyoutSpellName, flyoutSpellSubname, flyoutSpellID)
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addPolymorphOrHexFlyoutSpell_func: START");
local flyoutSpellFullName = flyoutSpellName.. "(".. flyoutSpellSubname.. ")";
if not SN2SID_table[universalClassName].Flyouts[flyoutButton][flyoutSpellFullName]
or SN2SID_table[universalClassName].Flyouts[flyoutButton][flyoutSpellFullName] ~= flyoutSpellID then
-- print(AddonName.. "Adding flyout spellFullName ".. flyoutSpellFullName.. " = ".. flyoutSpellID);
SN2SID_table[universalClassName].Flyouts[flyoutButton][flyoutSpellFullName] = flyoutSpellID;
end
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addPolymorphOrHexFlyoutSpell_func: END");
end
 
local addFlyoutSpells_func = function(flyoutButtonName, flyoutButtonID)
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addFlyoutSpells_func: START");
-- print(AddonName.. ": SpellID ".. flyoutButtonID.. " on SpecTab ".. i.. ", Pos ".. ii.. " is a FLYOUT button.");
-- NB: Creating SN2SID_table[universalClassName].Flyouts either via
-- SN2SID_table[universalClassName].Flyouts = []; or via
-- tinsert(SN2SID_table[universalClassName], "Flyouts"); was causing a bug where the same
-- table would have two "Flyouts" fields: one with the correct values and another empty
-- (as if it were a simple member of an array). So we create a STUB value if needed and
-- later remove it when we're done adding the spells.
if not SN2SID_table[universalClassName].Flyouts then
SN2SID_table[universalClassName].Flyouts = { ["STUB"] = 0, };
end
 
if (flyoutButtonName == "Portal") or (flyoutButtonName == "Teleport") then
-- There are spells with the same Name but different IDs, depending on the
-- character's faction, when it comes to Portals and Teleports. Hence, for now,
-- we add them only in Post. TODO: Fetch them here as well, but check that they
-- are not one of those (known) smae-name, diff-IDs cases (in that case do not add
-- them here, only in post).
else
-- Insert the flyout spell in its proper table
if not SN2SID_table[universalClassName].Flyouts[flyoutButtonName] then
-- print(AddonName.. ": Adding Flyouts.".. flyoutButtonName.. " to ".. universalClassName);
SN2SID_table[universalClassName].Flyouts[flyoutButtonName] = { ["STUB"] = 0, };
-- else
-- print(AddonName.. ": Flyouts.".. flyoutButtonName.. " is already in ".. universalClassName);
end
local _, _, numFlyouts, flyoutKnown = GetFlyoutInfo(flyoutButtonID);
-- print(AddonName.. ": ".. flyoutButtonName.. " | ".. flyoutButtonID.. " | Number of Slots = ".. numFlyouts);
for flyoutSlot = 1, numFlyouts do
-- local flyoutSpellID, overrideSpellID, flyoutSlotKnown, slotSpecID = GetFlyoutSlotInfo(flyoutButtonID, flyoutSlot);
local flyoutSpellID, _, _, _ = GetFlyoutSlotInfo(flyoutButtonID, flyoutSlot);
local flyoutSpellName, flyoutSpellSubname, _, _, _, _, _ = GetSpellInfo(flyoutSpellID);
if flyoutButtonName == "Polymorph Variants" or flyoutButtonName == "Hex Variants" then
-- Mage "Polymorph Variants", and Shaman "Hex Variants",
-- are all called "Polymorph" or "Hex", respectively. But
-- they have a subname specifying the variant AND can be
-- addressed by suffixing the subname in parenthesis, as
-- in e.g. "Polymorph(Sheep)" or "Hex(Frog)". We'll do just
-- that and store their names as "name(subname)".
if (flyoutSpellSubname == nil) or (flyoutSpellSubname == "") then
-- print(AddonName.. ": ".. tostring(flyoutSpellName).. " = ".. tostring(flyoutSpellID));
-- TODO #1: Make a table, LOCAL-TO-FILE, to store
-- all the delayedFlyoutSpellInfo tables amd name
-- each one "delayedFlyoutSpellInfo"..flyoutSpellID .
-- Create an access to the info that will be fetched
local delayedFlyoutSpellInfo = Spell:CreateFromSpellID(flyoutSpellID);
-- Actually get the info and use it to update our DB
delayedFlyoutSpellInfo:ContinueOnSpellLoad(function()
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": delayedFlyoutSpellInfo:ContinueOnSpellLoad: START");
-- print(AddonName.. ": Will now get the previously delayed information about flyoutSpellID: ".. flyoutSpellID);
-- Although we should only need to update spellSubName, we might
-- have fetched a new spellName + spellID by now. Thus, we'll
-- update those fields too.
-- TODO #2: Pass the three
-- "delayedFlyoutSpellInfo"..flyoutSpellID:Some()
-- values bellow as arguments to
-- addPolymorphOrHexFlyoutSpell_func(...)
flyoutSpellName = delayedFlyoutSpellInfo:GetSpellName();
flyoutSpellSubname = delayedFlyoutSpellInfo:GetSpellSubtext(); -- Mandatory
flyoutSpellID = delayedFlyoutSpellInfo:GetSpellID();
addPolymorphOrHexFlyoutSpell_func(flyoutButtonName, flyoutSpellName, flyoutSpellSubname, flyoutSpellID);
-- TODO #3: Clean up! I.e.:
-- SaidMasterTable["delayedFlyoutSpellInfo"..flyoutSpellID] = nil;
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": delayedFlyoutSpellInfo:ContinueOnSpellLoad: END");
end);
else
-- print(AddonName.. ": ".. tostring(flyoutSpellName).. " = ".. tostring(flyoutSpellID));
addPolymorphOrHexFlyoutSpell_func(flyoutButtonName, flyoutSpellName, flyoutSpellSubname, flyoutSpellID);
end
-- Add the default Plymorph(Sheep) and Hex(Frog) to the spell lists
if universalClassName == MAGE then
SN2SID_table.MAGE.Arcane["Polymorph(Sheep)"] = SN2SID_table.MAGE.Arcane["Polymorph"] or nil;
SN2SID_table.MAGE.Fire["Polymorph(Sheep)"] = SN2SID_table.MAGE.Fire["Polymorph"] or nil;
SN2SID_table.MAGE.Frost["Polymorph(Sheep)"] = SN2SID_table.MAGE.Frost["Polymorph"] or nil;
end
if universalClassName == SHAMAN then
SN2SID_table.SHAMAN.Elemental["Hex(Frog)"] = SN2SID_table.SHAMAN.Elemental["Hex"] or nil;
SN2SID_table.SHAMAN.Enhancement["Hex(Frog)"] = SN2SID_table.SHAMAN.Enhancement["Hex"] or nil;
SN2SID_table.SHAMAN.Restoration["Hex(Frog)"] = SN2SID_table.SHAMAN.Restoration["Hex"] or nil;
end
elseif flyoutSpellName and (not SN2SID_table[universalClassName].Flyouts[flyoutButtonName][flyoutSpellName])
or flyoutSpellName and (SN2SID_table[universalClassName].Flyouts[flyoutButtonName][flyoutSpellName] ~= flyoutSpellID) then
-- print(AddonName.. ": ".. tostring(flyoutSpellName).. " = ".. tostring(flyoutSpellID));
SN2SID_table[universalClassName].Flyouts[flyoutButtonName][flyoutSpellName] = flyoutSpellID;
end
end
SN2SID_table[universalClassName].Flyouts[flyoutButtonName]["STUB"] = nil;
end
-- Get rid of the STUB table member that was added upon its creation
SN2SID_table[universalClassName].Flyouts["STUB"] = nil;
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addFlyoutSpells_func: END");
end
-- --
 
-- Update the Spellbook's GeneralTab and ClassTabs lists of spells
-- local updateSpellbookSpells_func = function(SN2SID_table, SN2SID_PASSIVES_table, generalTabName, universalClassName, ClassNumSpecs, ClassSpecNames2IDs)
-- local updateSpellbookSpells_func = function(generalTabName, universalClassName, ClassNumSpecs, ClassSpecNames2IDs)
-- local updateSpellbookSpells_func = function(universalClassName, ClassNumSpecs, ClassSpecNames2IDs)
local updateSpellbookSpells_func = function(ClassNumSpecs, ClassSpecNames2IDs)
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateSpellbookSpells_func: START");
-- "Armor Skills" and "Weapon Skills" are found on the Spellbook's General tab, but are indeed
-- different from one class to the other. Therefore, we'll save them into local variables upon
-- fetching the General tab spells and then insert them into the Class Specialisations' tables.
1255,6 → 1084,7
 
-- General tab spells
-- if updateGeneralSpells then -- In current addon version, always true
-- local _, universalRaceName = UnitRace("player");
local stubVal;
stubVal, universalRaceName = UnitRace("player");
if not SN2SID_table[generalTabName].Racials then
1278,12 → 1108,14
if not SN2SID_PASSIVES_table[generalTabName].Others then
SN2SID_PASSIVES_table[generalTabName].Others = {};
end
-- local generalTabName, _, offset, numEntries, _, _, _ = GetSpellTabInfo(1);
generalTabName, _, offset, numEntries, _, _, _ = GetSpellTabInfo(1);
-- name, texture, offset, numEntries, isGuild, offspecID = GetSpellTabInfo(tabIndex)
for i = offset +1, offset +numEntries do
local spellName, spellSubName = GetSpellBookItemName(i, BOOKTYPE_SPELL);
if spellName then
local _, spellID = GetSpellBookItemInfo(i, BOOKTYPE_SPELL);
-- NEW for 1.0.14 --
if (spellSubName == nil) or (spellSubName == "") then
local delayedSpellInfo = Spell:CreateFromSpellID(spellID);
-- I presume we don't actually need to cancel the request for the additional
1318,7 → 1150,6
-- end);
-- Actually get the information and use it to update our database:
delayedSpellInfo:ContinueOnSpellLoad(function()
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": delayedSpellInfo:ContinueOnSpellLoad: START");
-- print(AddonName.. ": Will now get the previously delayed information about spell ID: ".. spellID);
-- Although we should only need to update spellSubName, we might
-- have fetched a new spellName + spellID by now. Thus, we'll
1330,7 → 1161,6
-- Now cancel the request:
-- spellDataLoadedCancelFunc();
-- spellDataLoadedCancelFunc = nil; -- for safety!
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": delayedSpellInfo:ContinueOnSpellLoad: END");
end);
--[[
local spellDataLoadedCancelFunc = delayedSpellInfo:ContinueWithCancelOnSpellLoad(function()
1409,8 → 1239,6
-- If it's a Flyout type of button (e.g. Mage Polymorph variants, Hunter Pet
-- Utility spells, etc), then fetch the spells that ... fly out.
if spellType == "FLYOUT" then
addFlyoutSpells_func(spellName, spellID);
--[[
-- print(AddonName.. ": SpellID ".. spellID.. " on SpecTab ".. i.. ", Pos ".. ii.. " is a FLYOUT button.");
-- NB: Creating SN2SID_table[universalClassName].Flyouts either via
-- SN2SID_table[universalClassName].Flyouts = []; or via
1497,7 → 1325,6
end
-- Get rid of the STUB table member that was added upon its creation
SN2SID_table[universalClassName].Flyouts["STUB"] = nil;
]]--
end
end
end
1509,7 → 1336,6
end
updateClassSpells = false;
-- end
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updateSpellbookSpells_func: END");
end
 
 
1522,8 → 1348,8
-- which names would be the tokens (string) above?
 
-- Add one Pet Spell to the apropriate subtable
-- local addSpellbookPetSpell_func = function(spellName, spellSubName, spellID, petFamily)
local addSpellbookPetSpell_func = function(spellName, spellSubName, spellID)
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addSpellbookPetSpell_func: START");
local isPassive = IsPassiveSpell(spellID);
if strfind(spellSubName, "Special") or strfind(spellSubName, "Bonus") or strfind(spellSubName, "Exotic") then -- Pet Family ability
if isPassive then
1648,12 → 1474,11
end
end
end
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addSpellbookPetSpell_func: END");
end
 
-- Pet Spells update function
-- local updatePetSpellNames = function(SN2SID_table, SN2SID_PASSIVES_table, universalClassName)
local updatePetSpellNames = function()
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updatePetSpellNames: START");
-- print(AddonName.. ": Fetching Pet spells");
-- local petHasSpellsConfirmed = false;
-- NOTES:
1731,7 → 1556,6
-- end);
-- Actually get the information and use it to update our database:
delayedSpellInfo:ContinueOnSpellLoad(function()
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": delayedSpellInfo: START");
-- print(AddonName.. ": Will now get the previously delayed information about spell ID: ".. spellID);
-- Although we should only need to update spellSubName, we might
-- have fetched a new spellName + spellID by now. Thus, we'll
1743,7 → 1567,6
-- Now cancel the request:
-- spellDataLoadedCancelFunc();
-- spellDataLoadedCancelFunc = nil; -- for safety!
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": delayedSpellInfo: END");
end);
else
addSpellbookPetSpell_func(spellName, spellSubName, spellID);
1840,60 → 1663,67
-- petHasSpellsConfirmed = true;
end
-- print(AddonName.. ": Fetched? ".. tostring(petHasSpellsConfirmed));
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": updatePetSpellNames: END");
end
 
 
-- local addSpellsPostUpdate = function(SN2SID_table, SN2SID_PASSIVES_table, generalTabName, universalClassName)
-- local addSpellsPostUpdate = function(SN2SID_table, SN2SID_PASSIVES_table)
local addSpellsPostUpdate = function()
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addSpellsPostUpdate: START");
if postUpdate_Spells2Add and SN2SID_table then -- Sanity check
-- Sanity check
if (postUpdate_Spells2Add ~= nil) and (SN2SID_table ~= nil) then
for key, value in pairs(postUpdate_Spells2Add) do
if key == "General" or key == universalClassName then -- Only add hardcoded spells for
-- GeneralTab or Current Class
-- if SN2SID_table[key] == nil then -- Sanity check, key == "General" OR universalClassName
if not SN2SID_table[key] then -- Sanity check, key == "General" OR universalClassName
-- print(AddonName.. ": Adding: ".. tostring(value));
SN2SID_table[key] = value
elseif type(value) == "table" then -- Should always be 'true' i.e. always either
-- specName(..somethingMaybe) OR "Flyouts" OR
-- "Pets" OR someGeneralTabCategory.
for keyk, valuev in pairs(value) do
if keyk == "FlyoutsTOGET" then
-- print(AddonName.. ": Will get flyout spells for FlyoutButtonName ".. keykk.. " with ID ".. valuevv);
-- addFlyoutSpells_func(keyk, valuev);
for keykk, valuevv in pairs(valuev) do
addFlyoutSpells_func(keykk, valuevv);
end
elseif not SN2SID_table[key][keyk] then -- specName(..somethingMaybe)
-- OR "FlyoutsTOGET" OR
-- "Flyouts" OR "Pets" OR
-- someGeneralTabCategory.
-- if SN2SID_table[key][keyk] == nil then -- specName(..somethingMaybe) OR
if not SN2SID_table[key][keyk] then -- specName(..somethingMaybe) OR
-- "Flyouts" OR "Pets" OR
-- someGeneralTabCategory.
-- print(AddonName.. ": Adding: ".. tostring(valuev));
SN2SID_table[key][keyk] = valuev;
elseif type(valuev) == "table" then
elseif type(valuev) == "table" then --
--
for keykk, valuevv in pairs(valuev) do
if not SN2SID_table[key][keyk][keykk] then -- Spell OR Flyouts_spell OR
-- PetFamily is not on the
-- target table yet
-- if SN2SID_table[key][keyk][keykk] == nil then -- Spell OR Flyouts_spell OR
if not SN2SID_table[key][keyk][keykk] then -- Spell OR Flyouts_spell OR
-- PetFamily is not on the
-- target table yet
-- print(AddonName.. ": Adding: ".. tostring(valuevv));
SN2SID_table[key][keyk][keykk] = valuevv;
end
if type(valuevv) == "table" then -- Flyouts_spell OR PetFamily
for keykkk, valuevvv in pairs(valuevv) do
if not SN2SID_table[key][keyk][keykk][keykkk] then
-- Flyouts_spell_Spell OR
-- PetFamily_spell is not
-- yet on the table.
for keykkk, valuevvv in pairs(valuevv) do
-- if SN2SID_table[key][keyk][keykk][keykkk] == nil then -- Flyouts_spell_Spell OR
if not SN2SID_table[key][keyk][keykk][keykkk] then -- Flyouts_spell_Spell OR
-- PetFamily_spell is not
-- on the target table yet
-- print(AddonName.. ": Adding: ".. tostring(valuevvv));
SN2SID_table[key][keyk][keykk][keykkk] = valuevvv;
end
end
 
end
end
 
end
end
 
 
end
end
end
 
if postUpdate_Spells2Add_PASSIVES and SN2SID_PASSIVES_table then
if (postUpdate_Spells2Add_PASSIVES ~= nil) and (SN2SID_PASSIVES_table ~= nil) then
for key, value in pairs(postUpdate_Spells2Add_PASSIVES) do
if key == "General" or key == universalClassName then -- Only add hardcoded spells for
-- GeneralTab or Current Class
-- if SN2SID_PASSIVES_table[key] == nil then -- Sanity check, key == "General" OR universalClassName
if not SN2SID_PASSIVES_table[key] then -- Sanity check, key == "General" OR universalClassName
-- print(AddonName.. ": Adding: ".. tostring(value));
SN2SID_PASSIVES_table[key] = value;
elseif type(value) == "table" then -- Should always be 'true' i.e. always either "Spells"
-- OR specName(..somethingMaybe) OR "Pets"
for keyk, valuev in pairs(value) do
-- if SN2SID_PASSIVES_table[key][keyk] == nil then -- "Spells" OR specName(..somethingMaybe) OR
if not SN2SID_PASSIVES_table[key][keyk] then -- "Spells" OR specName(..somethingMaybe) OR
1929,7 → 1759,6
end
end
end
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": addSpellsPostUpdate: END");
end
 
 
1943,77 → 1772,60
 
-- Function to call upon PLAYER_LOGIN (see bottom of file)
local lsn2sidpStartup = function()
tinsert(DEBUGmsgs[DBG_CurrentEvent], tostring(GetTime()).. ": lsn2sidpStartup: START");
-- Startup --
print(AddonName.. ": Startup!");
-- Copy the global saved-variables tables to our local tables
-- local SN2SID_table = AddonEnv.SpellNamesAndIDs or SpellNamesAndIDs or {};
-- local SN2SID_PASSIVES_table = AddonEnv.SpellNamesAndIDs_PASSIVES or SpellNamesAndIDs_PASSIVES or {};
SN2SID_table = AddonEnv.SpellNamesAndIDs or SpellNamesAndIDs or {};
SN2SID_PASSIVES_table = AddonEnv.SpellNamesAndIDs_PASSIVES or SpellNamesAndIDs_PASSIVES or {};
-- DEBUGmsgs = AddonEnv.DEBUG_messages or DEBUG_messages or {};
 
-- tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Print tables\' tostring to console: START");
-- print(AddonName.. ": AddonEnv.SpellNamesAndIDs = ".. tostring(AddonEnv.SpellNamesAndIDs)); -- nil
-- print(AddonName.. ": AddonEnv.SpellNamesAndIDs_PASSIVES = ".. tostring(AddonEnv.SpellNamesAndIDs_PASSIVES)); -- nil
-- print(AddonName.. ": AddonEnv.DEBUG_messages = ".. tostring(AddonEnv.DEBUG_messages)); -- nil
-- print(AddonName.. ": SpellNamesAndIDs = ".. tostring(SpellNamesAndIDs)); -- TableA
-- print(AddonName.. ": SpellNamesAndIDs_PASSIVES = ".. tostring(SpellNamesAndIDs_PASSIVES)); -- TableB
-- print(AddonName.. ": DEBUG_messages = ".. tostring(DEBUG_messages)); -- TableB
-- print(AddonName.. ": SN2SID_table = ".. tostring(SN2SID_table));-- TableA
-- print(AddonName.. ": SN2SID_PASSIVES_table = ".. tostring(SN2SID_PASSIVES_table)); -- TableB
-- print(AddonName.. ": DEBUGmsgs = ".. tostring(DEBUGmsgs)); -- TableB
-- tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Print tables\' tostring to console: END");
 
-- -- Metadata fields: Data source, Class', ... -- --
-- Data source --
-- We're only interested in storing the English names, at least for now
local curLocale = GetLocale();
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Got: curLocale = ".. curLocale);
if ( curLocale ~= "enUS") then
SN2SID_frame:UnregisterAllEvents();
error(AddonName.. " only retrieves data from English (enUS or enGB) clients.");
-- return;
return;
end
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Validated: curLocale");
local stubVal;
stubVal, universalRaceName = UnitRace("player");
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Got: universalRaceName (no validation needed) = ".. universalRaceName);
-- Self-explanatory:
local _, gameBuild = GetBuildInfo();
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Got: gameBuild");
-- For some reason, the variable gameBuild is being saved as a string; convert to number:
gameBuild = tonumber(gameBuild);
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Validated that gameBuild is a number. gameBuild = ".. gameBuild.. ": Done.");
local charLevel = UnitLevel("player");
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Got: charLevel (no validation needed) = ".. charLevel);
-- Spells in the General tab: Racial abilities, etc
-- local generalTabName = (GetSpellTabInfo(1)); -- Tab#1 = General
generalTabName = (GetSpellTabInfo(1)); -- Tab#1 = General
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Got: generalTabName (no validation needed) = ".. generalTabName);
-- Class stuff --
-- local universalClassName = select(2, UnitClass("player")); -- Locale-independent Class name
stubVal, universalClassName = UnitClass("player"); -- Locale-independent Class name
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Got: universalClassName (no validation needed) = ".. universalClassName);
local ClassNumSpecs = GetNumSpecializations(false, false); -- Number of Specialisations
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Got: ClassNumSpecs (no validation needed) = ".. ClassNumSpecs);
-- Ordered list of Class specs' IDs and Names -- Do we still use this?
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Order list of Class specs' IDs and Names: START");
local specID, specName = GetSpecializationInfo(1);
local ClassSpecNames2IDs = {};
for i = 1, ClassNumSpecs do
local specID, specName = GetSpecializationInfo(i);
ClassSpecNames2IDs[specName] = specID;
end
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Order list of Class specs' IDs and Names: END");
 
---- Check the tables' skeleton structure and build whatever may be missing ----
--
if not SN2SID_table then -- sanity check
error(AddonName.. "Local copy of saved variables is missing.");
-- return;
return;
end
if not SN2SID_PASSIVES_table then -- sanity check
error(AddonName.. "Local copy of saved variables is missing.");
-- return;
return;
end
--
-- If needed, create and populate the Metadata subtables; --
2023,9 → 1835,9
-- NB: We separate the two types of tables in two if-loops for the sake of sanity-keep (against
-- e.g. manual edits to the file).
if not SN2SID_table[generalTabName] then
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. generalTabName.. " dataSource for Active spells: START");
print(AddonName.. ": Will now create the ".. generalTabName.. " dataSource for Active spells.");
SN2SID_table[generalTabName] = {};
-- SN2SID_table[generalTabName].Spells = {};
SN2SID_table[generalTabName].METADATA = {};
SN2SID_table[generalTabName].METADATA.dataSource = {
clientLocale = curLocale, -- Currently always enUS
2037,15 → 1849,14
-- We've just created and populated the GeneralTabMetadata, hence no need to update
updateGeneralTabMetadata = false;
updateGeneralSpells = true; -- Do populate the actual list of spells
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. generalTabName.. " dataSource for Active spells: END");
else
updateGeneralTabMetadata = true; -- Will check whether it's updated; if not, will update;
-- The function which checks above var will also flag for Spells-list update if needed.
end
if not SN2SID_PASSIVES_table[generalTabName] then
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. generalTabName.. " dataSource for Passive spells: START");
print(AddonName.. ": Will now create the ".. generalTabName.. " dataSource for Passive spells.");
SN2SID_PASSIVES_table[generalTabName] = {};
-- SN2SID_PASSIVES_table[generalTabName].Spells = {};
SN2SID_PASSIVES_table[generalTabName].METADATA = {};
SN2SID_PASSIVES_table[generalTabName].METADATA.dataSource = {
clientLocale = curLocale, -- Currently always enUS
2055,16 → 1866,19
};
SN2SID_PASSIVES_table[generalTabName].METADATA.raceBuilds = { [universalRaceName] = gamebuild };
-- We've just created and populated the GeneralTabMetadata, hence no need to update ...
updateGeneralTabMetadata = false; -- And this seems redundant. Keep it 'cause I'll forget it otherwise...
if not updateGeneralTabMetadata then -- ... unless it's needed for the Active spells
updateGeneralTabMetadata = false; -- And this seems redundant. Keep it 'cause I'll forget it otherwise...
end
updateGeneralSpells = true; -- Do populate the actual list of spells
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. generalTabName.. " dataSource for Passive spells: END");
else
updateGeneralTabMetadata = true; -- Will check whether it's updated, if not will update;
-- The function which checks above var will also flag for Spells-list update if needed.
end
-- Run the update function (does both Active and Passive trees)
-- Run the update function (does both Active and Passive trees), delayed
-- updateGeneralTabMetadata_func(SN2SID_table, SN2SID_PASSIVES_table, curLocale, gameBuild, universalRaceName, generalTabName, charLevel);
-- updateGeneralTabMetadata_func(curLocale, gameBuild, universalRaceName, generalTabName, charLevel);
-- updateGeneralTabMetadata_func(curLocale, gameBuild, universalRaceName, charLevel);
updateGeneralTabMetadata_func(curLocale, gameBuild, charLevel);
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Updated the ".. generalTabName.. " Metadata \(or not\!\) for both Active and Passive spells.");
 
-- Class spells' Metadata (dataSource only; class Specs will be handled afterwards)
if not SN2SID_table[universalClassName] then
2072,10 → 1886,9
SN2SID_table[universalClassName] = {};
else
updateClassMetadata = true; -- Will check whether it's updated and if not, will update;
-- The function which checks above var will also flag for Spells-list update if needed.
-- The function which checks above var will also flag for Spells-list update if needed.
end
if not SN2SID_table[universalClassName].METADATA then
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. universalClassName.. " dataSource for Active spells: START");
SN2SID_table[universalClassName].METADATA = {};
SN2SID_table[universalClassName].METADATA.dataSource = {
clientLocale = curLocale, -- Currently always enUS
2087,21 → 1900,29
-- Class Specs fields are updated in another if-clause, further ahead.
updateClassMetadata = false;
updateClassSpells = true; -- Do populate the actual list of spells.
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. universalClassName.. " dataSource for Active spells: END");
else
updateClassMetadata = true; -- Will check whether it's updated and if not, will update;
-- The function which checks above var will also flag for Spells-list update if needed.
end
 
if not SN2SID_PASSIVES_table[universalClassName] then
print(AddonName.. ": Will now create the ".. universalClassName.. "'s table and dataSource for Passive spells.");
SN2SID_PASSIVES_table[universalClassName] = {};
SN2SID_PASSIVES_table[universalClassName].METADATA = {};
SN2SID_PASSIVES_table[universalClassName].METADATA.dataSource = {
clientLocale = curLocale, -- Currently always enUS
gameBuild = gameBuild,
charLevel = charLevel,
charMaxLevel = charLevel,
};
if not updateClassMetadata then -- See above, in the Actives snippet
updateClassMetadata = false;
end
updateClassSpells = true; -- Do populate the actual list of spells.
else
updateClassMetadata = true;
-- The function which checks above var will also flag for Spells-list update if needed.
end
 
if not SN2SID_PASSIVES_table[universalClassName].METADATA then
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. universalClassName.. " dataSource for Passive spells: START");
SN2SID_PASSIVES_table[universalClassName].METADATA = {};
SN2SID_PASSIVES_table[universalClassName].METADATA.dataSource = {
clientLocale = curLocale, -- Currently always enUS
2113,7 → 1934,6
-- Class Specs fields are updated in another if-clause, further ahead.
updateClassMetadata = false;
updateClassSpells = true; -- Do populate the actual list of spells.
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. universalClassName.. " dataSource for Passive spells: END");
else
updateClassMetadata = true; -- Will check whether it's updated and if not, will update;
-- The function which checks above var will also flag for Spells-list update if needed.
2123,12 → 1943,10
-- updateClassMetadata_func(SN2SID_table, SN2SID_PASSIVES_table, curLocale, gameBuild, universalClassName, charLevel);
-- updateClassMetadata_func(curLocale, gameBuild, universalClassName, charLevel);
updateClassMetadata_func(curLocale, gameBuild, charLevel);
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Ran updateClassMetadata_func().");
 
-- If needed, create and populate Class Specs' Active and Passive Spells --
-- Flag spell-lists for update if applicable --
if not SN2SID_table[universalClassName].METADATA.Specs then
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. universalClassName.. " \'Specs\' (Actives) tables: START");
print(AddonName.. ": Will now create the ".. universalClassName.. "'s \'Specs\' (Actives) tables.");
for i = 1, ClassNumSpecs do
local specID, specName = GetSpecializationInfo(i);
2146,10 → 1964,8
end
end
updateClassSpells = true; -- Do populate the actual list of spells.
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. universalClassName.. " \'Specs\' (Actives) tables: END");
end
if not SN2SID_PASSIVES_table[universalClassName].METADATA.Specs then
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. universalClassName.. " \'Specs\' (Passives) tables: START");
print(AddonName.. ": Will now create the ".. universalClassName.. "'s \'Specs\' (Passives) tables.");
for i = 1, ClassNumSpecs do
local specID, specName = GetSpecializationInfo(i);
2166,7 → 1982,6
end
end
updateClassSpells = true; -- Do populate the actual list of spells.
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Create the ".. universalClassName.. " \'Specs\' (Passives) tables: END");
end
 
-- Update General (always ATM) and Class SpellNames2SIDs (both Actives and Passives) --
2183,20 → 1998,15
---------------------------------
 
function SN2SID_events:PLAYER_TALENT_UPDATE(self)
DBG_CurrentEvent = "PLAYER_TALENT_UPDATE";
DEBUGmsgs["PLAYER_TALENT_UPDATE"] = { tostring(GetTime()).. ": PLAYER_TALENT_UPDATE: START", }
-- updateGeneralSpells = true; -- unneeded, placeholder for future version
updateClassSpells = true;
-- updateSpellbookSpells_func(SN2SID_table, SN2SID_PASSIVES_table, generalTabName, universalClassName, ClassNumSpecs, ClassSpecNames2IDs);
-- updateSpellbookSpells_func(generalTabName, universalClassName, ClassNumSpecs, ClassSpecNames2IDs);
-- updateSpellbookSpells_func(universalClassName, ClassNumSpecs, ClassSpecNames2IDs);
updateSpellbookSpells_func(ClassNumSpecs, ClassSpecNames2IDs);
tinsert(DEBUGmsgs["PLAYER_TALENT_UPDATE"], tostring(GetTime()).. ": PLAYER_TALENT_UPDATE: END");
end
 
function SN2SID_events:PLAYER_LEVEL_UP(self, ...)
DBG_CurrentEvent = "PLAYER_LEVEL_UP";
DEBUGmsgs["PLAYER_LEVEL_UP"] = { tostring(GetTime()).. ": PLAYER_LEVEL_UP: START", }
-- UnitLevel("player") doesn't update its result soon enough to have it indicate the *new*
-- char level in response to this event. OTH, this event does provide arguments but,
-- whatever they are, they're NOT the new char leve, for sure. Might be best to just flag
2207,7 → 2017,6
updateClassMetadata_func(curLocale, gameBuild, charLevel);
updateGeneralTabMetadata = true; -- Maybe useful.
updateClassMetadata = true; -- Stuff like talents only become available at level 10.
tinsert(DEBUGmsgs["PLAYER_LEVEL_UP"], tostring(GetTime()).. ": PLAYER_LEVEL_UP: END");
end
 
-- Update pets' existence and spells when one comes up for "player"
2222,8 → 2031,6
if (not arg1) or (arg1 ~= "player") then
return;
end
DBG_CurrentEvent = "UNIT_PET";
DEBUGmsgs["UNIT_PET"] = { tostring(GetTime()).. ": UNIT_PET: START", }
if not SN2SID_table[universalClassName].Pets then
SN2SID_table[universalClassName].Pets = {};
end
2233,58 → 2040,56
-- updatePetSpellNames(SN2SID_table, SN2SID_PASSIVES_table, universalClassName);
-- updatePetSpellNames(universalClassName);
updatePetSpellNames();
tinsert(DEBUGmsgs["UNIT_PET"], tostring(GetTime()).. ": UNIT_PET: END");
end
 
function SN2SID_events:PLAYER_LOGOUT(self)
DBG_CurrentEvent = "PLAYER_LOGOUT";
-- Set up DEBUG = { LOGOUT = {} } subtable of messages
if not DEBUGmsgs["PLAYER_LOGOUT"] then
DEBUGmsgs["PLAYER_LOGOUT"] = {
tostring(GetTime()).. ": PLAYER_LOGOUT: START",
tostring(GetTime()).. ": DEBUGmsgs.PLAYER_LOGOUT created.",
};
else
DEBUGmsgs["PLAYER_LOGOUT"] = {
tostring(GetTime()).. ": PLAYER_LOGOUT: START",
tostring(GetTime()).. ": DEBUGmsgs.PLAYER_LOGOUT cleared.",
};
-- WoW 8.0.1: PET_SPECIALIZATION_CHANGED doesn't seem to be firing anymore
--[[
-- Switch Hunter pet's specialisation
-- function SN2SID_events:PET_SPECIALIZATION_CHANGED(self, ...)
function SN2SID_events:PET_SPECIALIZATION_CHANGED(...)
local arg1 = ...;
print(AddonName.. ": PET_SPECIALIZATION_CHANGED fired with arg1 = ".. tostring(arg1));
if arg1 and arg1 ~= "player" then
return;
end
if not SN2SID_table[universalClassName].Pets then
SN2SID_table[universalClassName].Pets = {};
end
-- updatePetSpellNames(SN2SID_table, SN2SID_PASSIVES_table, universalClassName);
-- updatePetSpellNames(universalClassName);
updatePetSpellNames();
end
]]--
 
function SN2SID_events:PLAYER_LOGOUT(self)
-- Bring everything up to date
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Update some variables\' values: START");
charLevel = UnitLevel("player");
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": charLevel's value = ".. tostring(charLevel));
updateGeneralTabMetadata = true;
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": updateGeneralTabMetadata's value = ".. tostring(updateGeneralTabMetadata));
updateClassMetadata = true;
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": updateClassMetadata's value = ".. tostring(updateClassMetadata));
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Update some variables\' values: END");
 
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Update Metadata: START");
-- updateGeneralTabMetadata_func(SN2SID_table, SN2SID_PASSIVES_table, curLocale, gameBuild, universalRaceName, generalTabName, charLevel);
-- updateClassMetadata_func(SN2SID_table, SN2SID_PASSIVES_table, curLocale, gameBuild, universalClassName, charLevel);
-- updateSpellbookSpells_func(SN2SID_table, SN2SID_PASSIVES_table, generalTabName, universalClassName, ClassNumSpecs, ClassSpecNames2IDs);
-- updateGeneralTabMetadata_func(curLocale, gameBuild, universalRaceName, generalTabName, charLevel);
-- updateGeneralTabMetadata_func(curLocale, gameBuild, universalRaceName, charLevel);
updateGeneralTabMetadata_func(curLocale, gameBuild, charLevel);
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Updated GeneralTab Metadata.");
-- updateClassMetadata_func(curLocale, gameBuild, universalClassName, charLevel);
updateClassMetadata_func(curLocale, gameBuild, charLevel);
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Updated ".. universalClassName.. " Metadata.");
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Update Metadata: END");
 
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Update Spellbook spells: START");
-- updateSpellbookSpells_func(generalTabName, universalClassName, ClassNumSpecs, ClassSpecNames2IDs);
-- updateSpellbookSpells_func(universalClassName, ClassNumSpecs, ClassSpecNames2IDs);
updateSpellbookSpells_func(ClassNumSpecs, ClassSpecNames2IDs);
-- NB: UNIT_PET fires upon summoning new pets; but NOT upon switching Hunters' Pet-Specs.
if SN2SID_table[universalClassName].Pets or SN2SID_PASSIVES_table[universalClassName].Pets
or UnitExists("pet") then
-- updatePetSpellNames(SN2SID_table, SN2SID_PASSIVES_table, universalClassName);
-- updatePetSpellNames(universalClassName);
updatePetSpellNames();
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Updated Pet spells.");
else
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": NO Pet Spells to get.");
end
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Update Spellbook spells: END");
 
-- "Manually" add spells we cannot (or is not convenient to) get automatically
-- REENABLE THIS AFTER TEST:
addSpellsPostUpdate();
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Added hardcoded spells to General and Class tables.");
 
-- Copy our local tables to the global saved-variables tables --
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Copy session\'s Active and Passive Spells' tables to SavedVariables: START");
if AddonEnv.SpellNamesAndIDs then
AddonEnv.SpellNamesAndIDs = SN2SID_table;
else
2295,15 → 2100,6
else
SpellNamesAndIDs_PASSIVES = SN2SID_PASSIVES_table;
end
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Copy session\'s Active and Passive Spells' tables to SavedVariables: END");
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Copy the DEBUG messages to SavedVariables: START");
if AddonEnv.DEBUG_messages then
AddonEnv.DEBUG_messages = DEBUGmsgs;
else
DEBUG_messages = DEBUGmsgs;
end
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": Copy the DEBUG messages to SavedVariables: END");
tinsert(DEBUGmsgs["PLAYER_LOGOUT"], tostring(GetTime()).. ": PLAYER_LOGOUT: END");
end
 
-- Unregister the event (handler) in which we are now running
2312,7 → 2108,6
SN2SID_frame:SetScript("OnEvent", function(self, event, ...)
SN2SID_events[event](self, ...);
end);
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Unregistered Event: PLAYER_LOGIN");
for k, v in pairs(SN2SID_events) do
if k == "UNIT_PET" then
SN2SID_frame:RegisterUnitEvent("UNIT_PET", "player");
2322,27 → 2117,10
-- if SN2SID_frame:IsEventRegistered(k) then
-- print(AddonName.. ": Registered event: ".. tostring(k));
-- end
tinsert(DEBUGmsgs["PLAYER_LOGIN"], tostring(GetTime()).. ": Registered Event: ".. k);
end
tinsert(DEBUGmsgs["PLAYER_LOGIN"], (GetTime()).. ": PLAYER_LOGIN: END");
end
 
-- PLAYER_LOGIN event handler; we set up the other events when this one fires --
SN2SID_frame:SetScript("OnEvent", function(self, event)
DBG_CurrentEvent = "PLAYER_LOGIN";
DEBUGmsgs = AddonEnv.DEBUG_messages or DEBUG_messages or {};
if not DEBUGmsgs then
DEBUGmsgs = {
["PLAYER_LOGIN"] = {
tostring(GetTime()).. ": PLAYER_LOGIN: START",
tostring(GetTime()).. ": Will startup in 5 seconds time.",
},
};
else
DEBUGmsgs["PLAYER_LOGIN"] = {
tostring(GetTime()).. ": PLAYER_LOGIN: START",
tostring(GetTime()).. ": Will startup in 5 seconds time.",
};
end
C_Timer.After(5, lsn2sidpStartup);
C_Timer.After(3, lsn2sidpStartup);
end);
populator/trunk/LibSpellName2SID-1.1-Populator/LibSpellName2SID-1.1-Populator.toc
2,8 → 2,8
## Title: LibSpellName2SID-1.1: Populator (DEV)
## Notes: Get all spells from a character and save them to file.
## Author: aallkkaa
## Version: 1.1.03
## SavedVariables: SpellNamesAndIDs, SpellNamesAndIDs_PASSIVES, DEBUG_messages
## Version: 1.1.01
## SavedVariables: SpellNamesAndIDs, SpellNamesAndIDs_PASSIVES
## DefaultState: disabled
## X-Category: Development