Mercurial > wow > ouroloot
changeset 20:d89aeb6b9f9e
Put in slower but portable loot pattern matching, finally.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Thu, 01 Sep 2011 02:03:14 +0000 |
parents | f560cf82e7d3 |
children | 41e735c1b91f |
files | core.lua gui.lua verbage.lua |
diffstat | 3 files changed, 62 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/core.lua Mon Aug 29 01:29:13 2011 +0000 +++ b/core.lua Thu Sep 01 02:03:14 2011 +0000 @@ -82,6 +82,7 @@ } local my_name = UnitName('player') local comm_cleanup_ttl = 5 -- seconds in the cache +local g_LOOT_ITEM_ss, g_LOOT_ITEM_MULTIPLE_sss, g_LOOT_ITEM_SELF_s, g_LOOT_ITEM_SELF_MULTIPLE_ss ------ Addon member data @@ -141,7 +142,7 @@ -- This is an amalgamation of all four LOOT_ITEM_* patterns. -- Captures: 1 person/You, 2 itemstring, 3 rest of string after final |r until '.' -- Can change 'loot' to 'item' to trigger on, e.g., extracting stuff from mail. - loot_pattern = "(%S+) receives? loot:.*|cff%x+|H(.-)|h.*|r(.*)%.$" + --loot_pattern = "(%S+) receives? loot:.*|cff%x+|H(.-)|h.*|r(.*)%.$" bossmod_registered = nil bossmods = {} @@ -414,6 +415,30 @@ end end + --[[ + The four loot format patterns of interest, changed into relatively tight + string match patterns. Done at enable-time rather than load-time against + the slim chance that one of the non-US "delocalizers" needs to mess with + the global patterns before we transform them. + + The SELF variants can be replaced with LOOT_ITEM_PUSHED_SELF[_MULTIPLE] to + trigger on 'receive item' instead, which would detect extracting stuff + from mail, or s/PUSHED/CREATED/ for things like healthstones and guild + cauldron flasks. + ]] + + -- LOOT_ITEM = "%s receives loot: %s." --> (.+) receives loot: (.+)%. + g_LOOT_ITEM_ss = _G.LOOT_ITEM:gsub('%.$','%%.'):gsub('%%s','(.+)') + + -- LOOT_ITEM_MULTIPLE = "%s receives loot: %sx%d." --> (.+) receives loot: (.+)(x%d+)%. + g_LOOT_ITEM_MULTIPLE_sss = _G.LOOT_ITEM_MULTIPLE:gsub('%.$','%%.'):gsub('%%s','(.+)'):gsub('x%%d','(x%%d+)') + + -- LOOT_ITEM_SELF = "You receive loot: %s." --> You receive loot: (.+)%. + g_LOOT_ITEM_SELF_s = _G.LOOT_ITEM_SELF:gsub('%.$','%%.'):gsub('%%s','(.+)') + + -- LOOT_ITEM_SELF_MULTIPLE = "You receive loot: %sx%d." --> You receive loot: (.+)(x%d+)%. + g_LOOT_ITEM_SELF_MULTIPLE_ss = _G.LOOT_ITEM_SELF_MULTIPLE:gsub('%.$','%%.'):gsub('%%s','(.+)'):gsub('x%%d','(x%%d+)') + if self.debug.flow then self:Print"is in control-flow debug mode." end end --function addon:OnDisable() end @@ -667,18 +692,37 @@ if event == "CHAT_MSG_LOOT" then local msg = ... - --ChatFrame2:AddMessage("original string: >"..(msg:gsub("\124","\124\124")).."<") - local person, itemstring, remainder = msg:match(self.loot_pattern) - self.dprint('loot', "CHAT_MSG_LOOT, person is", person, ", itemstring is", itemstring, ", rest is", remainder) - if not person then return end -- "So-and-So selected Greed", etc, not actual looting - local count = remainder and remainder:match(".*(x%d+)$") + local person, itemstring, count + ChatFrame2:AddMessage("original string: >"..(msg:gsub("\124","\124\124")).."<") + --local person, itemstring, remainder = msg:match(self.loot_pattern) + + -- test in most likely order: other people get more loot than "you" do + person, itemstring, count = msg:match(g_LOOT_ITEM_MULTIPLE_sss) + if not person then + person, itemstring = msg:match(g_LOOT_ITEM_ss) + end + if not person then + itemstring, count = msg:match(g_LOOT_ITEM_SELF_MULTIPLE_ss) + if not itemstring then + itemstring = msg:match(g_LOOT_ITEM_SELF_s) + end + end + + --self.dprint('loot', "CHAT_MSG_LOOT, person is", person, ", itemstring is", itemstring, ", rest is", remainder) + self.dprint('loot', "CHAT_MSG_LOOT, person is", person, ", itemstring is", itemstring, ", count is", count) + if not itemstring then return end -- "So-and-So selected Greed", etc, not actual looting + --local count = remainder and remainder:match(".*(x%d+)$") -- Name might be colorized, remove the highlighting - local p = person:match("|c%x%x%x%x%x%x%x%x(%S+)") - person = p or person - person = (person == UNIT_YOU) and my_name or person + if person then + person = person:match("|c%x%x%x%x%x%x%x%x(%S+)") or person + else + -- UNIT_YOU / You + person = my_name + end - local id = tonumber((select(2, strsplit(":", itemstring)))) + --local id = tonumber((select(2, strsplit(":", itemstring)))) + local id = tonumber(itemstring:match('|Hitem:(%d+):')) return self:_do_loot (false, person, id, count)
--- a/gui.lua Mon Aug 29 01:29:13 2011 +0000 +++ b/gui.lua Thu Sep 01 02:03:14 2011 +0000 @@ -1404,13 +1404,16 @@ w:SetCallback("OnClick", function() collectgarbage() end) grp:AddChild(w) + --[==[ this has been well and truly debugged by now w = mkbutton("EditBox", nil, addon.loot_pattern:sub(17), [[]]) w:SetRelativeWidth(0.35) w:SetLabel("CML pattern suffix") w:SetCallback("OnEnterPressed", function(_w,event,value) addon.loot_pattern = addon.loot_pattern:sub(1,16) .. value end) - grp:AddChild(w) + grp:AddChild(w) ]==] + + w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(1) grp:AddChild(w) local simple = GUI:Create("SimpleGroup") simple:SetLayout("List")
--- a/verbage.lua Mon Aug 29 01:29:13 2011 +0000 +++ b/verbage.lua Thu Sep 01 02:03:14 2011 +0000 @@ -419,6 +419,10 @@ Using the "Saved Texts" feature plus the +Clear> button is a great way of putting off pasting loot into your guild's website until a more convenient time. + +All of the choices in the right-click dropdown menus have tooltips with some +additional information, but these only appear when the Blizzard option "Beginner +Tooltips" is enabled (Interface - Game - Help - Beginner Tooltips). ]] T.tips_slashies = [[