From a237d9c06ba448672188af0b7769689542e6005f Mon Sep 17 00:00:00 2001 From: pigmonkey Date: Mon, 30 May 2011 18:13:08 -0400 Subject: [PATCH] Fixed an absurd amount of bugs, which serves me right for not testing a single module before making them all --- AllTheLittleThings.lua | 37 +++++++++++++++++------------ AllTheLittleThings.toc | 4 +--- modules/announce.lua | 11 +++++---- modules/battlegrounds.lua | 31 +++++++++++++------------ modules/chatfilter.lua | 12 ++++++---- modules/defaultui.lua | 14 ----------- modules/deprecated.lua | 43 +++++++++++++++++----------------- modules/guildroster.lua | 49 ++++++++++++++++++++------------------- modules/macros.lua | 31 +++++++++++++------------ modules/miscellaneous.lua | 43 +++++++++++++++++----------------- modules/potions.lua | 13 ++++++----- modules/prat.lua | 3 ++- modules/raid.lua | 5 ++-- modules/rbs.lua | 3 ++- modules/staging.lua | 14 +++++++++++ modules/template.lua | 8 +++---- 16 files changed, 169 insertions(+), 152 deletions(-) delete mode 100644 modules/defaultui.lua create mode 100644 modules/staging.lua diff --git a/AllTheLittleThings.lua b/AllTheLittleThings.lua index d181b5b..6569ded 100644 --- a/AllTheLittleThings.lua +++ b/AllTheLittleThings.lua @@ -18,44 +18,47 @@ local options = { }, } local slashCallback = {} +local slashList = {} + +local prototype = {} +core:SetDefaultModulePrototype(prototype) +core:SetDefaultModuleLibraries("AceConsole-3.0") function core:OnInitialize() - self.db = LibStub("AceDB-3.0"):New("AllTheLittleThingsDB", defaults, "Default") + self.db = LibStub("AceDB-3.0"):New("AllTheLittleThingsDB", defaults, "Default") or {} self:RegisterChatCommand("atlt", "MainSlashHandle") - -- LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("AllTheLittleThings", options) - -- local ACD = LibStub("AceConfigDialog-3.0") - -- ACD:AddToBlizOptions("AllTheLittleThings", "AllTheLittleThings") - - self:SetDefaultModulePrototype({ - RegisterOptions = core.RegisterOptions, - RegisterSlashCommand = core.RegisterSlashCommand, - }) + LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("AllTheLittleThings", options) + local ACD = LibStub("AceConfigDialog-3.0") + ACD:AddToBlizOptions("AllTheLittleThings", "AllTheLittleThings") end function core:OnEnable() - end function core:OnDisable() - end -- two registry functions called with self=mod -function core:RegisterOptions(options, defaults) +function core:RegisterOptions(modOptions, modDefaults) local name = self:GetName() - defaults.profile[name] = defaults + defaults.profile[name] = modDefaults options.args[name] = { name = name, type = 'group', - args = options + args = modOptions } end function core:RegisterSlashCommand(callback, ...) + local long = "" for i=1,select('#', ...) do - slashCallback[select('i', ...)] = self[callback] + local slash = select(i, ...) + slashCallback[slash] = self[callback] + long = string.len(slash)>string.len(long) and slash or long end + + slashList[long] = ("%s:%s()"):format(self:GetName(), callback) end function core:MainSlashHandle(msg) @@ -69,3 +72,7 @@ function core:MainSlashHandle(msg) end end +-- fill out our prototype now that our addon's indicies are populated +prototype.RegisterOptions = core.RegisterOptions +prototype.RegisterSlashCommand = core.RegisterSlashCommand + diff --git a/AllTheLittleThings.toc b/AllTheLittleThings.toc index 2ceea86..180798e 100644 --- a/AllTheLittleThings.toc +++ b/AllTheLittleThings.toc @@ -23,8 +23,6 @@ AllTheLittleThings.lua modules\announce.lua modules\battlegrounds.lua modules\chatfilter.lua -modules\defaultui.lua -# modules\deprecated.lua modules\guildroster.lua modules\macros.lua modules\miscellaneous.lua @@ -32,5 +30,5 @@ modules\potions.lua modules\prat.lua modules\raid.lua modules\rbs.lua -modules\template.lua +modules\staging.lua diff --git a/modules/announce.lua b/modules/announce.lua index c24aa51..d327e28 100644 --- a/modules/announce.lua +++ b/modules/announce.lua @@ -1,6 +1,6 @@ local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") -local mod = core:NewModule("Announce", "AceEvent-3.0") -local db = core.db.profile[mod:GetName()] +local mod = core:NewModule("Announce", "AceEvent-3.0", "AceTimer-3.0") +local db local defaults = { interrupt = false, @@ -56,15 +56,16 @@ local armorGlyphs = { } function mod:OnInitialize() - core:RegisterOptions(options, defaults) - core:RegisterSlashCommand("method", "slsh1", "slash2") + db = core.db.profile[self:GetName()] or {} + self:RegisterOptions(options, defaults) + self:RegisterSlashCommand("method", "slsh1", "slash2") end function mod:OnEnable() self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") end -function core:COMBAT_LOG_EVENT_UNFILTERED(_, timestamp, event, _, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellid, spellName, spellSchool, extraSpellid, extraSpellName, ...) +function mod:COMBAT_LOG_EVENT_UNFILTERED(_, timestamp, event, _, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags, spellid, spellName, spellSchool, extraSpellid, extraSpellName, ...) -- Interrupt ------------------------------------------------------------------ if db.interrupt and GetNumPartyMembers()>0 then if event == "SPELL_INTERRUPT" and srcName == UnitName("player") then diff --git a/modules/battlegrounds.lua b/modules/battlegrounds.lua index 14e614d..8d0e5d0 100644 --- a/modules/battlegrounds.lua +++ b/modules/battlegrounds.lua @@ -1,6 +1,6 @@ -local core = LibStub("AceAddon-4.0"):GetAddon("AllTheLittleThings") -local mod = core:NewModule("Battlegrounds", "AceEvent-3.0", "AceConsole-3.0") -local db = core.db.profile[mod:GetName()] +local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") +local mod = core:NewModule("Battlegrounds", "AceEvent-3.0", "AceHook-3.0") +local db local defaults = { autoWG = false, @@ -25,12 +25,13 @@ local gilneasTimes = { -- time in seconds to get a point [2] = 3, [3] = 1/3, } -core.wgStatus = 0 -core.flagStatus = 0 +local wgStatus = 0 +local flagStatus = 0 function mod:OnInitialize() - core:RegisterOptions(options, defaults) - core:RegisterSlash("ArathiPrint", "ab", "arathibasin") + db = core.db.profile[self:GetName()] or {} + self:RegisterOptions(options, defaults) + self:RegisterSlashCommand("ArathiPrint", "ab", "arathibasin") end function mod:OnEnable() @@ -96,12 +97,12 @@ function mod:BATTLEFIELD_MGR_ENTRY_INVITE() end -- Eye of the Storm ------------------------------------------------------------ -function core:BattlegroundMessage(event, msg) +function mod:BattlegroundMessage(event, msg) local faction = ((event=="CHAT_MSG_BG_SYSTEM_ALLIANCE" and 1) or 2) if string.find(msg, "captured.+flag") or string.find(msg, "dropped.+flag") then - self.flagStatus = 0 + flagStatus = 0 elseif string.find(msg, "taken.+flag") then - self.flagStatus = faction + flagStatus = faction end end @@ -109,15 +110,15 @@ function mod:WorldStateAlwaysUpFrame_Update(...) self.hooks["WorldStateAlwaysUpFrame_Update"](...) if db.eotsFlag and GetRealZoneText() == "Eye of the Storm" then local points = {[0]=0, 75, 85, 100, 500} - if self.flagStatus > 0 then - local i = self.flagStatus + 1 + if flagStatus > 0 then + local i = flagStatus + 1 if select(3, GetWorldStateUIInfo(i)) then -- extra if since I got a lua error while leaving a BG once local _, _, full, bases, score = string.find(select(3, GetWorldStateUIInfo(i)), "(Bases: (%d).-(%d+)/.+)") if not full then return end -- self:Print(string.find(select(3, GetWorldStateUIInfo(i)), "(Bases: (%d).-(%d+)/.+)")) -- self:Print(GetWorldStateUIInfo(i)) local nScore = "|cff00ff00" .. (tonumber(score)+points[tonumber(bases)]) .. "|r" - local frame = _G["AlwaysUpFrame"..self.flagStatus.."Text"] + local frame = _G["AlwaysUpFrame"..flagStatus.."Text"] if frame then frame:SetText(string.gsub(full, score.."/", nScore.."/")) end @@ -127,8 +128,8 @@ function mod:WorldStateAlwaysUpFrame_Update(...) end -- function mod:OnKeyDown() --- if self.wgStatus > 0 and GetRealZoneText() ~= "Wintergrasp" then --- self.wgStatus = 0 +-- if wgStatus > 0 and GetRealZoneText() ~= "Wintergrasp" then +-- wgStatus = 0 -- BattlefieldMgrEntryInviteResponse(1, 1) -- end -- end diff --git a/modules/chatfilter.lua b/modules/chatfilter.lua index 2938de2..5b03d80 100644 --- a/modules/chatfilter.lua +++ b/modules/chatfilter.lua @@ -1,6 +1,6 @@ local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") local mod = core:NewModule("Chat Filter") -local db = core.db.profile[mod:GetName()] +local db local defaults = { } @@ -13,6 +13,11 @@ local options = { } function mod:OnInitialize() + db = core.db.profile[self:GetName()] or {} + -- self:FilterAll("achievement:284") + self:FilterAll(nil, "Alabrooke") + self:FilterAll(nil, "Warrwarr") + end local chatEvents = { @@ -81,7 +86,7 @@ local chatEvents = { local contentFilters = { } local sourceFilters = { } -function core:FilterAll(filter, source) +function mod:FilterAll(filter, source) if not db.filterOn then return end if filter or source then @@ -105,6 +110,3 @@ function core:FilterAll(filter, source) end end --- core:FilterAll("achievement:284") -core:FilterAll(nil, "Alabrooke") -core:FilterAll(nil, "Warrwarr") diff --git a/modules/defaultui.lua b/modules/defaultui.lua deleted file mode 100644 index af15b03..0000000 --- a/modules/defaultui.lua +++ /dev/null @@ -1,14 +0,0 @@ -local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") -local mod = core:NewModule("Battlegrounds", "AceEvent-3.0") -local db = core.db.profile[mod:GetName()] - -local defaults = { -} -local options = { -} - -function mod:OnInitialize() - core:RegisterOptions(options, defaults) - core:RegisterSlashCommand("method", "slsh1", "slash2") -end - diff --git a/modules/deprecated.lua b/modules/deprecated.lua index 5dc6089..d5f2a2a 100644 --- a/modules/deprecated.lua +++ b/modules/deprecated.lua @@ -1,7 +1,7 @@ -- These are here for historical purposes only -- do not include in .toc local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") local mod = core:NewModule("Deprecated", "AceEvent-3.0") -local db = core.db.profile[mod:GetName()] +local db local defaults = { macroSwap = false, @@ -15,13 +15,14 @@ local options = { } function mod:OnInitialize() - core:RegisterOptions(options, defaults) - core:RegisterSlashCommand("method", "slsh1", "slash2") + db = core.db.profile[self:GetName()] or {} + self:RegisterOptions(options, defaults) + self:RegisterSlashCommand("method", "slsh1", "slash2") end -- Lich King Flame Cap Macro --------------------------------------------------- local macro = "MI+FC"; -function core:ZoneChange() +function mod:ZoneChange() if (db.macroSwap and UnitName("player")=="Chira" and GetMacroIndexByName(macro)>0) then if (GetSubZoneText() == "The Frozen Throne" and self:GetMode()>3) then EditMacro(GetMacroIndexByName(macro), nil, nil, GetMacroBody(macro):gsub("Flame Caq", "Flame Cap")); @@ -31,13 +32,13 @@ function core:ZoneChange() end end -function core:GetMode() +function mod:GetMode() local _, _, diff, _, _, dynHeroic, dynFlag = GetInstanceInfo(); return diff; -- (dynFlag and (2-(diff%2)+2*dynHeroic)) or diff; end -- Attempt to monitor n52 problem ---------------------------------------------- -function core:Nostromo() +function mod:Nostromo() local keys = {"W", "A", "S", "D"} local xVal = {1, 0, 1, 2} local yVal = {0, 1, 1, 1} @@ -75,9 +76,9 @@ function core:Nostromo() end -- creates a text string and hooks every CLEU to try and find a problematic addon -function core:SetupAddonDebug() +function mod:SetupAddonDebug() local frame = CreateFrame("frame") - frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", self.db.profile.addonDebug.x, self.db.profile.addonDebug.y) + frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", db.addonDebug.x, db.addonDebug.y) frame:SetSize(100, 30) frame:EnableMouse(true) frame:SetMovable(true) @@ -88,8 +89,8 @@ function core:SetupAddonDebug() end) frame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() - core.db.profile.addonDebug.x = self:GetLeft() - core.db.profile.addonDebug.y = self:GetTop() + db.addonDebug.x = self:GetLeft() + db.addonDebug.y = self:GetTop() end) local text = frame:CreateFontString(nil, nil, "GameFontNormal") @@ -127,7 +128,7 @@ function core:SetupAddonDebug() end -- Bug with text in animations ------------------------------------------------- -function core:BugInit() +function mod:BugInit() local f = CreateFrame("frame") f:SetSize(50, 50) f:SetPoint("CENTER") @@ -189,7 +190,7 @@ local function my_hash(key, ...) end -- Saampson Shards and Deathblood Venom deposit -------------------------------- -function core:CHAT_MSG_LOOT(_, message, source) +function mod:CHAT_MSG_LOOT(_, message, source) -- if (message:find("Saampson") and message:find("Shadowfrost Shard")) then -- SendChatMessage(format("Saampson Shard Count: %d", math.random(15, 50)), "raid"); -- end @@ -212,10 +213,10 @@ function core:CHAT_MSG_LOOT(_, message, source) end -- Consolidate Thresh -function core:UnitAura(...) +function mod:UnitAura(...) name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID = self.hooks["UnitAura"](...) - if expires and (self.db.profile.consolidateThresh > 0) then - if ((expires-GetTime())/60 > self.db.profile.consolidateThresh) or (name:find("Aura") or name:find("Totem")) or (shouldConsolidate == 1) then + if expires and (db.consolidateThresh > 0) then + if ((expires-GetTime())/60 > db.consolidateThresh) or (name:find("Aura") or name:find("Totem")) or (shouldConsolidate == 1) then shouldConsolidate = 1 else shouldConsolidate = nil @@ -227,7 +228,7 @@ end -- Slash Commands -function core:SlashProcess(msg) +function mod:SlashProcess(msg) if msg == "ilevel" or msg == "il" then self:RaidDump("Tallying iLevel Sums...") r = {} @@ -253,7 +254,7 @@ function core:SlashProcess(msg) self:RaidDump("---") elseif msg == "markxp" then -- write all current - local db = self.db.profile.guildXPMarks + local db = db.guildXPMarks or {} local num = #db+1 db[num] = { @@ -280,7 +281,7 @@ function core:SlashProcess(msg) self:Print(format("Created new mark set #%d; suggested UI reload", num)) elseif msg:find("diff ") then local setNum = tonumber(msg:match("diff (%d+)")) - local set = setNum and self.db.profile.guildXPMarks[setNum] + local set = setNum and db.guildXPMarks[setNum] if not set then self:Print(format("Could not find split %d", setNum)) @@ -397,7 +398,7 @@ end -- Hallow's end self.hallowBuff = nil -function core:UNIT_AURA(_, unit) +function mod:UNIT_AURA(_, unit) -- if we haven't set the initial value yet, set and quit if (self.hallowBuff == nil) then self.hallowBuff = not not UnitDebuff("player", "Tricked or Treated") @@ -414,10 +415,10 @@ function core:UNIT_AURA(_, unit) self:Print("Halloween debuff lost!"); self.hallowBuff = false; elseif (not self.hallowBuff and hasBuff()) then - self.db.profile.halloween = self.db.profile.halloween + 1; + db.halloween = db.halloween + 1; -- pick transitive local transitive = TRANSITIVES[math.random(#TRANSITIVES)]; - self:Print(format("I will %s %d babies this year", transitive, self.db.profile.halloween)) + self:Print(format("I will %s %d babies this year", transitive, db.halloween)) self.hallowBuff = true; end end diff --git a/modules/guildroster.lua b/modules/guildroster.lua index 23336ac..b88e614 100644 --- a/modules/guildroster.lua +++ b/modules/guildroster.lua @@ -1,6 +1,6 @@ local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") local mod = core:NewModule("Guild Roster", "AceEvent-3.0", "AceHook-3.0") -local db = core.db.profile[mod:GetName()] +local db local defaults = { easyInvites = true, @@ -20,7 +20,8 @@ local rosterRaidersCount = 0 local rosterRaidersOnline = 0 function mod:OnInitialize() - core:RegisterOptions(options, defaults) + db = core.db.profile[self:GetName()] or {} + self:RegisterOptions(options, defaults) end function mod:OnEnable() @@ -91,7 +92,7 @@ end function mod:GuildRoster_Update() self:RosterUpdatePostHook() - local view = self.guildView or GuildRosterViewDropdown.selectedValue + local view = guildView or GuildRosterViewDropdown.selectedValue local buttons = GuildRosterContainer.buttons local offset = HybridScrollFrame_GetOffset(GuildRosterContainer); for i=1, #buttons do @@ -100,7 +101,7 @@ function mod:GuildRoster_Update() stripe:SetTexture(stripe.texture) end - if (UnitInRaid("player") and self.db.profile.easyInvites) then + if (UnitInRaid("player") and db.easyInvites) then if buttons[i].guildIndex then name = GetGuildRosterInfo(buttons[i].guildIndex) if name and UnitInRaid(name) and (view == "playerStatus" or view == "guildStatus") then @@ -159,7 +160,7 @@ function mod:RosterUpdatePostHook() local button, index, class; local totalMembers, onlineMembers = GetNumGuildMembers(); local selectedGuildMember = GetGuildRosterSelection(); - local currentGuildView = self.guildView or GuildRosterViewDropdown.selectedValue + local currentGuildView = guildView or GuildRosterViewDropdown.selectedValue if ( currentGuildView == "tradeskill" ) then return; @@ -316,7 +317,7 @@ function mod:RosterUpdatePostHook() end function mod:GuildRosterButton_OnClick(this, button, ...) - if self.db.profile.easyInvites and IsAltKeyDown() then + if db.easyInvites and IsAltKeyDown() then local guildIndex = this.guildIndex local name, _, _, _, _, _, _, _, online = GetGuildRosterInfo(guildIndex) if online then @@ -346,12 +347,12 @@ local function nameNum(ind) end function GetGuildRosterInfo(index) -- no need - if not core.rosterRaidersOnly then - -- core:Print("Request for", index, "FAILED: core.rosterRaidersOnly=",core.rosterRaidersOnly, " core.inRosterUpdate=", core.inRosterUpdate) + if not mod.rosterRaidersOnly then + -- mod:Print("Request for", index, "FAILED: mod.rosterRaidersOnly=",mod.rosterRaidersOnly, " mod.inRosterUpdate=", mod.inRosterUpdate) return GetGuildRosterInfoHook(index) end - local cache = core.rosterAlteredCache + local cache = mod.rosterAlteredCache local baseIndex = index -- the ACTUAL index that is mapped to whatever index is -- check cache @@ -359,15 +360,15 @@ function GetGuildRosterInfo(index) isRaider = false -- check if raider - if core:IsRaider(index) then + if mod:IsRaider(index) then -- if they are, set flag isRaider = true else -- if not, begin looking ahead for j=baseIndex+1,GetNumGuildMembers() do - if core:IsRaider(cache[j] or j) then + if mod:IsRaider(cache[j] or j) then -- when you find one, set foundIndex's cache to index and baseIndex's cache to foundIndex's - core:Print("Swapping",nameNum(baseIndex),"with",nameNum(j)) + mod:Print("Swapping",nameNum(baseIndex),"with",nameNum(j)) cache[j] = index cache[baseIndex] = j -- and set our locals @@ -379,12 +380,12 @@ function GetGuildRosterInfo(index) -- if you don't find one, index is unaltered end - core:Print("Request for", nameNum(baseIndex), "returning", nameNum(index), " isRaider =",isRaider) + mod:Print("Request for", nameNum(baseIndex), "returning", nameNum(index), " isRaider =",isRaider) -- check flag if they're a raider - if isRaider or not core.inRosterUpdate then + if isRaider or not mod.inRosterUpdate then -- if true, return actual stuff - if not GetGuildRosterShowOffline() and core.inRosterUpdate then + if not GetGuildRosterShowOffline() and mod.inRosterUpdate then local online = select(9, GetGuildRosterInfoHook(index)) if not online then return nil @@ -396,27 +397,27 @@ function GetGuildRosterInfo(index) -- if false, return nil end -function core:IsRaider(index) +function mod:IsRaider(index) local name, _, rank, _, _, _, note, _, online = GetGuildRosterInfoHook(index) -- if a raider+ rank, or below and linked to a raider -- not name tests for out of bounds check - if not name or ((rank <= 1) or (rank == 3) or ((rank == 4 or rank == 2) and online and self.rosterRaidersCache[note])) then + if not name or ((rank <= 1) or (rank == 3) or ((rank == 4 or rank == 2) and online and rosterRaidersCache[note])) then return true end return false end -function core:RosterUpdatePreHook() - wipe(self.rosterAlteredCache) - self.inRosterUpdate = true - if self.rosterRaidersOnly then +function mod:RosterUpdatePreHook() + wipe(rosterAlteredCache) + inRosterUpdate = true + if rosterRaidersOnly then self:Print("Update pre hook") end end -function core:RosterUpdatePostHook() - self.inRosterUpdate = false - if self.rosterRaidersOnly then +function mod:RosterUpdatePostHook() + inRosterUpdate = false + if rosterRaidersOnly then self:Print("Update post hook") end end]] diff --git a/modules/macros.lua b/modules/macros.lua index 52ecc94..caa47bf 100644 --- a/modules/macros.lua +++ b/modules/macros.lua @@ -1,6 +1,6 @@ local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") -local mod = core:NewModule("Macros", "AceTimer-3.0", "AceConsole-3.0") -local db = core.db.profile[mod:GetName()] +local mod = core:NewModule("Macros", "AceTimer-3.0") +local db local defaults = { } @@ -8,18 +8,19 @@ local options = { } function mod:OnInitialize() - core:RegisterOptions(options, defaults) - core:RegisterSlashCommand("DisbandRaid", "dr", "disbandraid") - core:RegisterSlashCommand("InviteGuild", "ig", "inviteguild") - core:RegisterSlashCommand("PromoteAll", "pa", "promoteall") - core:RegisterSlashCommand("DemoteAll", "da", "demoteall") - core:RegisterSlashCommand("PrintLoot", "pl", "printloot") - core:RegisterSlashCommand("ClearMarks", "cm", "clearmarks") - core:RegisterSlashCommand("MasterLoot", "ml", "masterloot") - core:RegisterSlashCommand("RandomLoot", "rl", "randomloot") - core:RegisterSlashCommand("FlaskCheck", "fc", "flaskcheck") - core:RegisterSlashCommand("Countdown", "cd", "countdown") - core:RegisterSlashCommand("RosterCheck", "rc", "rostercheck") + db = core.db.profile[self:GetName()] or {} + self:RegisterOptions(options, defaults) + self:RegisterSlashCommand("DisbandRaid", "dr", "disbandraid") + self:RegisterSlashCommand("InviteGuild", "ig", "inviteguild") + self:RegisterSlashCommand("PromoteAll", "pa", "promoteall") + self:RegisterSlashCommand("DemoteAll", "da", "demoteall") + self:RegisterSlashCommand("PrintLoot", "pl", "printloot") + self:RegisterSlashCommand("ClearMarks", "cm", "clearmarks") + self:RegisterSlashCommand("MasterLoot", "ml", "masterloot") + self:RegisterSlashCommand("RandomLoot", "rl", "randomloot") + self:RegisterSlashCommand("FlaskCheck", "fc", "flaskcheck") + self:RegisterSlashCommand("Countdown", "cd", "countdown") + self:RegisterSlashCommand("RosterCheck", "rc", "rostercheck") end function mod:DisbandRaid() @@ -92,7 +93,7 @@ function mod:RandomLoot() end end -function core:FlaskCheck() +function mod:FlaskCheck() local now = GetTime() for i=1,GetNumRaidMembers() do for j=1,32 do diff --git a/modules/miscellaneous.lua b/modules/miscellaneous.lua index 1014617..696820c 100644 --- a/modules/miscellaneous.lua +++ b/modules/miscellaneous.lua @@ -1,6 +1,6 @@ local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") -local mod = core:NewModule("Miscellaneous", "AceEvent-3.0", "AceConsole-3.0", "AceHook-3.0", "AceTimer-3.0") -local db = core.db.profile[mod:GetName()] +local mod = core:NewModule("Miscellaneous", "AceEvent-3.0", "AceHook-3.0", "AceTimer-3.0") +local db local defaults = { rollTally = true, @@ -38,10 +38,11 @@ local options = { } function mod:OnInitialize() - core:RegisterOptions(options, defaults) - core:RegisterSlashCommand("RollTally", "rt", "rolltally") - core:RegisterSlashCommand("FindPhones", "phone") - core:RegisterSlashCommand("ActiveTally", "at", "activetally") + db = core.db.profile[self:GetName()] or {} + self:RegisterOptions(options, defaults) + self:RegisterSlashCommand("RollTally", "rt", "rolltally") + self:RegisterSlashCommand("FindPhones", "phone") + self:RegisterSlashCommand("ActiveTally", "at", "activetally") -- allow max camera zoom ConsoleExec("cameradistancemaxfactor 5") @@ -157,20 +158,20 @@ end local rollTally = {} local rollTimer = false -function core:CHAT_MSG_RAID_WARNING(_, message) - if self.db.profile.rollTally and string.find(message:lower(), "roll") then - if self.rollTimer then +function mod:CHAT_MSG_RAID_WARNING(_, message) + if db.rollTally and string.find(message:lower(), "roll") then + if rollTimer then -- Stop current roll - self:CancelTimer(self.rollTimer) + self:CancelTimer(rollTimer) self:RollFinish() end rollTally = {} - self.rollTimer = self:ScheduleTimer("RollFinish", 10) + rollTimer = self:ScheduleTimer("RollFinish", 10) end end -function core:CHAT_MSG_SYSTEM(_, message, source) - if self.db.profile.rollTally and self.rollTimer then +function mod:CHAT_MSG_SYSTEM(_, message, source) + if db.rollTally and rollTimer then local name, roll, min, max = string.match(message, "(%S+) rolls (%d+) %((%d+)%-(%d+)%)") if name and roll and min and max then if min ~= "1" or max ~= "100" then @@ -189,7 +190,7 @@ function core:CHAT_MSG_SYSTEM(_, message, source) end end -function core:RollFinish() +function mod:RollFinish() local winner local ties = {} for i,v in pairs(rollTally) do @@ -215,17 +216,17 @@ function core:RollFinish() self:Print(string.format("%s won the roll with a %d.", winner, rollTally[winner])) end end - self.rollTimer = false + rollTimer = false end -function core:NixAFK(_, _, ...) - return (not not self.db.profile.nixAFK), ...; +function mod:NixAFK(_, _, ...) + return (not not db.nixAFK), ...; end -- Officer Phone --------------------------------------------------------------- -function core:CHAT_MSG_OFFICER(_, msg) +function mod:CHAT_MSG_OFFICER(_, msg) local _,_,numA,numB,numC = msg:find("!phone %(?(%d+)%)?.(%d+).(%d+)"); local _,_,name = msg:find("!phone (%w+)"); @@ -249,7 +250,7 @@ function core:CHAT_MSG_OFFICER(_, msg) SetGuildRosterShowOffline(setting); end -function core:CheckPhone(index) +function mod:CheckPhone(index) local name, rank, _, _, _, _, _, onote = GetGuildRosterInfo(index); local a, b, c = onote:match("%(?(%d%d%d)%)?.(%d%d%d).(%d%d%d%d)"); if (not rank:find("Alt") and not rank:find("Non")) then @@ -262,7 +263,7 @@ function core:CheckPhone(index) end -- Mark Star on Target --------------------------------------------------------- -function core:TargetUnit(name) +function mod:TargetUnit(name) if name and GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then self:RegisterEvent("UNIT_TARGET", function(_, unit) if unit == "player" then @@ -276,7 +277,7 @@ function core:TargetUnit(name) end -- Achieve Load ---------------------------------------------------------------- -function core:AchievementFrame_LoadUI(...) +function mod:AchievementFrame_LoadUI(...) local args = {self.hooks["AchievementFrame_LoadUI"](...)} AchievementFrame_SetFilter(3) self:Unhook("AchievementFrame_LoadUI") diff --git a/modules/potions.lua b/modules/potions.lua index fee4cab..78c3550 100644 --- a/modules/potions.lua +++ b/modules/potions.lua @@ -1,6 +1,6 @@ local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") local mod = core:NewModule("Potion Mail", "AceEvent-3.0") -local db = core.db.profile[mod:GetName()] +local db local defaults = { } @@ -18,7 +18,8 @@ local potList = { local mailQueue = {} -- used in /atlt pots function mod:OnInitialize() - core:RegisterSlashCommand("AddPotions", "pots") + db = core.db.profile[self:GetName()] or {} + self:RegisterSlashCommand("AddPotions", "pots") end function mod:OnEnable() @@ -81,7 +82,7 @@ end - add a command to display how much left of each is needed vs how much you have ]] local mailQueueTimer -function core:MailQueueCheck(caller, passData) +function mod:MailQueueCheck(caller, passData) local name,data = next(mailQueue) if not data then return -- no need to process queue @@ -155,7 +156,7 @@ function core:MailQueueCheck(caller, passData) print("Checking item count:", inv, ct, inv