Browse Source

Replace SpellNames2IDs.lua with UnitCastingSpellID

pull/1/head
xanthics 3 years ago
parent
commit
cb331dae9f
  1. 28
      TradeSkillMaster_Crafting/Modules/CraftingGUI.lua
  2. 4314
      TradeSkillMaster_Crafting/Modules/SpellNames2IDs.lua
  3. 2
      TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua

28
TradeSkillMaster_Crafting/Modules/CraftingGUI.lua

@ -85,6 +85,7 @@ function GUI:OnEnable()
GUI:RegisterEvent("TRADE_SKILL_FILTER_UPDATE", "EventHandler")
GUI:RegisterEvent("UPDATE_TRADESKILL_RECAST", "EventHandler")
GUI:RegisterEvent("CHAT_MSG_SKILL", "EventHandler")
GUI:RegisterEvent("UNIT_SPELLCAST_START", "EventHandler")
GUI:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED", "EventHandler")
GUI:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED", "EventHandler")
GUI:RegisterEvent("UNIT_SPELLCAST_FAILED", "EventHandler")
@ -248,18 +249,21 @@ function GUI:EventHandler(event, ...)
TSM.db.factionrealm.tradeSkills[UnitName("player")][skillName].level = level
TSM.db.factionrealm.tradeSkills[UnitName("player")][skillName].maxLevel = maxLevel
end
elseif event == "UNIT_SPELLCAST_START" then
local unit = ...
if unit ~= "player" then return end
TSM.currentspell = UnitCastingSpellID("player")
elseif event == "UNIT_SPELLCAST_SUCCEEDED" then
-- local unit, _, _, _, spellID = ... -- parameter ... doesn't provide spellID in 3.3.5a
local unit, spellName = ...
local spellID = TSM.SpellName2ID[spellName]
-- we only care about our spells
local unit = ...
if unit ~= "player" then return end
-- if spell is not related to crafting, ignore
local craft = TSM.currentspell and TSM.db.factionrealm.crafts[TSM.currentspell]
if not craft then return end
-- if spellID == nil then
-- TSM:Printf("Could not find spellID for %s", spellName)
-- end
local craft = spellID and TSM.db.factionrealm.crafts[spellID]
if unit ~= "player" or not craft then return end
-- decrements the number of this craft that are queued to be crafted
craft.queued = craft.queued - 1
if GUI.isCrafting and GUI.isCrafting.quantity > 0 then
@ -268,19 +272,17 @@ function GUI:EventHandler(event, ...)
--GUI:UpdateQueue()
end
end
TSM.currentspell = nil
-- TSMAPI:CreateTimeDelay("craftingQueueUpdateThrottle", 0.2, GUI.UpdateQueue)
elseif event == "UNIT_SPELLCAST_INTERRUPTED" or event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_FAILED_QUIET" then
-- local unit, _, _, _, spellID = ... -- parameter ... doesn't provide spellID in 3.3.5a
local unit, spellName = ...
local spellID = TSM.SpellName2ID[spellName]
local unit = ...
if unit ~= "player" then return end
-- if spellID == nil then
-- TSM:Printf("Could not find spellID for %s", spellName)
-- end
if unit ~= "player" then return end
if GUI.isCrafting and spellID == GUI.isCrafting.spellID then
if GUI.isCrafting and TSM.currentspell == GUI.isCrafting.spellID then
GUI.isCrafting.quantity = 0
TSMAPI:CreateTimeDelay("craftingQueueUpdateThrottle", 0.2, GUI.UpdateQueue)
end

4314
TradeSkillMaster_Crafting/Modules/SpellNames2IDs.lua

File diff suppressed because it is too large Load Diff

2
TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua

@ -67,6 +67,8 @@ function TSM:OnEnable()
end
end
end
-- if currently casting a spell, keep track of the id
TSM.currentspell = nil
if TSM.db.factionrealm.mats["item:52510"] then
local name = TSMAPI:GetSafeItemInfo("item:52510:0:0:0:0:0:0") or nil
TSM.db.factionrealm.mats["item:52510:0:0:0:0:0:0"] = {}

Loading…
Cancel
Save