From cd7ba55c82d407fbc11a5247b083474f28ad6247 Mon Sep 17 00:00:00 2001 From: SabinDeus Date: Thu, 9 Sep 2010 01:34:50 +0000 Subject: [PATCH] fixes for 3.3.3 function return values change and additional features --- README.txt | 8 +-- TurnIn.lua | 150 +++++++++++++++++++++++++++++++-------------------- TurnIn.toc | 4 +- TurnInUI.lua | 12 ++++- 4 files changed, 109 insertions(+), 65 deletions(-) diff --git a/README.txt b/README.txt index 3fbc0e9..6728d7c 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,5 @@ Turn In -v2.0 +v2.1 by Sabindeus of Smolderthorn/Andre of Argent Dawn (Alliance) DESCRIPTION @@ -32,6 +32,7 @@ COMMAND SUMMARY CHANGE LOG ------------- +v2.1 - Quest selection logic rewrite thanks to Arcanemagus of Hyjal v2.0 - Logic rewrite and added a real GUI for the new NPC DB. Updated for WoW 2.0. v1.3 - Greedy mode now actually works properly... I think. More to come! :/ v1.2 - Added Saved Variables. Turn In status now persists. Turn In now selects active quests and gossip options as well as available quests. Greedy mode lets you select an option regardless of if the one you wanted is availble. @@ -46,7 +47,8 @@ v1.0 - Initial Release -Special Thanks to Florrail for beta testing like a pro! +Special Thanks to Florrail and Makhno for beta testing like a pro! + +Extra Special Thanks to Arcanemagus for his code input! Please send bug reports, questions or comments to Sabin1936@mac.com -Thank you for downloading my add-on! \ No newline at end of file diff --git a/TurnIn.lua b/TurnIn.lua index b61c036..32ae11b 100644 --- a/TurnIn.lua +++ b/TurnIn.lua @@ -1,13 +1,11 @@ --[[ Turn-In Mod - version 2.0 + version 2.1 Authored by Ian Friedman - Sabindeus of Smolderthorn/Andre of Argent Dawn (Alliance) + Sabindeus of Smolderthorn (Alliance) The repeatable quest turn in automating machine. - todo: - make selection work for multiple active quests - + Thanks to Arcanemagus of Hyjal for extra bug fixes and coding input ]] TI_VersionString = "2.0"; @@ -205,7 +203,6 @@ function TI_SlashCmdHandler(cmd) else TI_message("Turn In Off"); end - TI_message(string.format("Option Number set to %d", TI_status.qnum)); end, window = function () TI_OptionsFrame:Show(); @@ -227,7 +224,7 @@ function TI_SlashCmdHandler(cmd) if(commands[cmdlist[1]]) then commands[cmdlist[1]](cmdlist[2], cmdlist[3], cmdlist[4]); else - TI_message("Turn In 2.0 Help", "--------------", "/ti on - turns Turn In on", "/ti off - turns Turn In off", "/ti toggle - toggles Turn In on or off", "/ti window - shows the options window", "/ti recent - shows the recently visited NPCs"); + TI_message("Turn In 2.1 Help", "--------------", "/ti on - turns Turn In on", "/ti off - turns Turn In off", "/ti toggle - toggles Turn In on or off", "/ti window - shows the options window", "/ti recent - shows the recently visited NPCs"); end @@ -387,8 +384,8 @@ function TI_HandleGossipWindow(gorq) local ActiveQuests; local GossipOptions; if(gorq == "g") then - AvailableQuests = TI_TabulateGossipQuests(GetGossipAvailableQuests()); - ActiveQuests = TI_TabulateGossipQuests(GetGossipActiveQuests()); + AvailableQuests = TI_TabulateGossipAvailableQuests(GetGossipAvailableQuests()); + ActiveQuests = TI_TabulateGossipActiveQuests(GetGossipActiveQuests()); GossipOptions = TI_TabulateGossipOptions(GetGossipOptions()); SAcQ = SelectGossipActiveQuest; SAvQ = SelectGossipAvailableQuest; @@ -409,6 +406,7 @@ function TI_HandleGossipWindow(gorq) x.gorq = gorq; x.args = i; x.type = "availquest"; + x.icon = v.icon; x.state = false; table.insert(ListEntry, x); end @@ -418,6 +416,7 @@ function TI_HandleGossipWindow(gorq) x.gorq = gorq; x.args = i; x.type = "activequest"; + x.icon = v.icon; x.state = false; table.insert(ListEntry, x); end @@ -439,54 +438,71 @@ function TI_HandleGossipWindow(gorq) return; end - local name = UnitName("npc"); - TI_AddNPCToTempList(name, ListEntry); - if(TI_status.autoadd and (not TI_NPCDB[name])) then - TI_debug("autoadd on, adding this NPC", TI_status.autoadd, TI_NPCDB[name]); - TI_AddNPCToList(ListEntry, name); + local npcname = UnitName("npc"); + TI_AddNPCToTempList(npcname, ListEntry); + + if(TI_status.autoadd and (not TI_NPCDB[npcname])) then + TI_debug("autoadd on, adding this NPC", TI_status.autoadd, TI_NPCDB[npcname]); + TI_AddNPCToList(ListEntry, npcname); end + -- If a NPC is in the Database but a new dialog option has appeared (new daily/completed quest) then add it to the DB + if (TI_NPCDB[npcname]) then + for k1, v1 in ipairs(ListEntry) do + local found = false; + for k2, v2 in ipairs(TI_NPCDB[npcname]) do + if (v2.type == v1.type and v2.name == v1.name) then + found = true; + end + end + if (not found) then + table.insert(TI_NPCDB[npcname], v1) + TI_PopulateOptions("npclist updated"); + end + end + end + if(TI_availnumber > TotalOptions or TI_activenumber > TotalOptions) then TI_ResetPointers(); return; end - --Legacy shit here - --[[ - if(TI_status.qnum ~= 0 and TI_status.qnum TI_specnum) then - TI_specnum = i; - TI_debug("Setting specnum to "..TI_specnum.." nothing under that will be picked"); - local flist = TI_FunctionList[current.gorq]; - if(flist[current.type]) then - flist[current.type](current.args); - else - flist["default"](current.args); + for i1,current in ipairs(thisnpc) do + if (current.state == true) then + TI_debug("Current Quest: "..current.name); + if (TI_specnum == 0 or i1 > TI_specnum) then + TI_specnum = i1; + if (current.type == "availquest") then + for i2,v2 in ipairs(AvailableQuests) do + if (v2.name == current.name) then + TI_debug(i1.."-Available Match Found: "..current.name); + TI_FunctionList[current.gorq]["availquest"](i2); + return; + end + end + elseif (current.type == "activequest") then + for i2,v2 in ipairs(ActiveQuests) do + if (v2.name == current.name) then + TI_debug(i1.."-Active Match Found: "..current.name..", "..current.type); + TI_FunctionList[current.gorq]["activequest"](i2); + return; + end + end + elseif (current.type == "gossip") then + for i2,v2 in ipairs(GossipOptions) do + if (v2.name == current.name) then + SelectGossipOption(i2); + return; + end + end end - return; end end end @@ -529,16 +545,6 @@ function TI_HandleGossipWindow(gorq) end function TI_AddNPCToList(OptList, npcname, confirminquestion) ---~ NPClist = { ---~ "Joe" = { ---~ 0 = { ---~ name = "Option 1" ---~ accessor = SelectGossipOption ---~ args = 0 ---~ } ---~ } ---~ } - if (npcname == nil) then npcname = UnitName("npc"); end @@ -607,19 +613,47 @@ function TI_TabulateGossipOptions(...) return x; end -function TI_TabulateGossipQuests(...) +function TI_TabulateGossipAvailableQuests(...) local x = {}; - local arg = {...}; - for i=1, #arg, 3 do + + for i=1, select("#", ...), 5 do local temp = {}; - temp.name = arg[i]; - temp.type = arg[i+1]; - temp.isLowLevel = arg[i+2] + temp.name = select(i, ...); + + isTrivial = select(i+2, ...); + isDaily = select(i+3, ...); + isRepeatable = select(i+4, ...); + if ( isDaily ) then + temp.icon = "Interface\\GossipFrame\\DailyQuestIcon"; + elseif ( isRepeatable ) then + temp.icon = "Interface\\GossipFrame\\DailyActiveQuestIcon"; + else + temp.icon = "Interface\\GossipFrame\\AvailableQuestIcon"; + end + table.insert(x, temp); end return x; end + +function TI_TabulateGossipActiveQuests(...) + local x = {}; + for i=1, select("#", ...), 4 do + local temp = {}; + temp.name = select(i, ...); + + isComplete = select(i+3, ...); + if(isComplete) then + temp.icon = "Interface\\GossipFrame\\ActiveQuestIcon"; + else + temp.icon = "Interface\\GossipFrame\\IncompleteQuestIcon"; + end + + table.insert(x, temp); + end + return x; +end --[[this function stolen from WhisperCast by Sarris, whom I love dearly for his contribution to Paladins everywhere. ]] diff --git a/TurnIn.toc b/TurnIn.toc index b1e2e8f..bc26d94 100644 --- a/TurnIn.toc +++ b/TurnIn.toc @@ -1,6 +1,6 @@ -## Interface: 30300 +## Interface: 40000 ## Title: Turn In ## Description: Automates the selection of quest and gossip options. ## SavedVariables: TI_status, TI_NPCDB, TI_NPCIndex -## Version: 2.0.12 +## Version: 2.1 TurnIn.xml \ No newline at end of file diff --git a/TurnInUI.lua b/TurnInUI.lua index a77097f..d4a8dfb 100644 --- a/TurnInUI.lua +++ b/TurnInUI.lua @@ -17,9 +17,17 @@ function TI_PopulateOptions(arg) if(v.name == nil) then TI_debug("oh noes") end; entrytext:SetText(v.name); if(v.type == "activequest") then - iconpath = "Interface\\GossipFrame\\ActiveQuestIcon"; + if(v.icon) then + iconpath = v.icon; + else + iconpath = "Interface\\GossipFrame\\ActiveQuestIcon"; + end elseif(v.type == "availquest") then - iconpath = "Interface\\GossipFrame\\AvailableQuestIcon"; + if(v.icon) then + iconpath = v.icon; + else + iconpath = "Interface\\GossipFrame\\AvailableQuestIcon"; + end else iconpath = "Interface\\GossipFrame\\" .. v.type .. "GossipIcon"; end