選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. --[[
  2. Turn-In Mod
  3. version 2.1
  4. Authored by Ian Friedman
  5. Sabindeus of Smolderthorn (Alliance)
  6. The repeatable quest turn in automating machine.
  7. Thanks to Arcanemagus of Hyjal for extra bug fixes and coding input
  8. ]]
  9. local addonName, addon = ...
  10. TI_VersionString = "2.0";
  11. local TI_slashtable;
  12. TI_gossipclosed = false;
  13. TI_LoadedNPCIndex = 0;
  14. TI_activenumber = 1;
  15. TI_availnumber = 1;
  16. TI_specnum = 0;
  17. TI_gossipopts = {};
  18. TI_TempNPCList = {};
  19. TI_TempNPCListMaxSize = 5;
  20. TI_NPCInQuestion = nil;
  21. local TI_FunctionList = {
  22. g = {
  23. availquest = SelectGossipAvailableQuest,
  24. activequest = SelectGossipActiveQuest,
  25. default = SelectGossipOption
  26. },
  27. q = {
  28. availquest = SelectAvailableQuest,
  29. activequest = SelectActiveQuest
  30. }
  31. };
  32. local TI_DefaultStatus = {
  33. state = false,
  34. version = TI_VersionString,
  35. options = {},
  36. debugstate = false,
  37. usedefault=true,
  38. autoadd=false
  39. };
  40. TI_TempNPCList = {};
  41. function TI_message(...)
  42. local x = {...};
  43. for k,v in pairs(x) do
  44. print(tostring(v));
  45. end
  46. end
  47. function TI_debug(...)
  48. if(TI_status.debugstate) then
  49. TI_message(...)
  50. end
  51. end
  52. function TI_OnLoad()
  53. SlashCmdList["TI"]=TI_SlashCmdHandler;
  54. SLASH_TI1="/turnin";
  55. SLASH_TI2="/ti";
  56. --tinsert(UISpecialFrames,"TI_OptionsFrame");
  57. TI_slashtable = {};
  58. TI_gossipopts = {};
  59. TI_gossipclosed = false;
  60. TurnIn:RegisterEvent("VARIABLES_LOADED");
  61. TI_activenumber = 1;
  62. TI_availnumber = 1;
  63. TI_specnum = 0;
  64. StaticPopupDialogs["TI_NPCINQUESTION"] = {
  65. text = "The NPC %s is already in your NPC Database. Do you wish to replace his gossip options with the current ones? (Note: This will overwrite your settings for this NPC.)",
  66. button1 = "Yes",
  67. button2 = "No",
  68. OnAccept = function()
  69. TI_AddNPCToList(TI_NPCInQuestion.list, TI_NPCInQuestion.name, true);
  70. end,
  71. timeout=0,
  72. whileDead = 1,
  73. hideOnEscape = 1
  74. };
  75. end
  76. function TI_VarInit()
  77. TI_debug("loading vars");
  78. if(not TI_status or TI_status.version ~= TI_VersionString) then
  79. TI_status = TI_copyTable(TI_DefaultStatus);
  80. TI_OptionsInit();
  81. end
  82. if(not TI_status.options or #TI_status.options == 0) then
  83. TI_OptionsInit();
  84. end
  85. if(not TI_NPCDB) then
  86. TI_NPCDB = {};
  87. end
  88. if(not TI_NPCIndex) then
  89. TI_NPCIndexGenerate();
  90. end
  91. TI_PopulateOptions("vars loaded");
  92. end
  93. --
  94. -- Events
  95. --
  96. local TI_EventHandlers = {}
  97. function TI_EventHandlers:QUEST_GREETING ()
  98. TI_debug("Quest Greeting");
  99. TI_lastquestframe = "greeting";
  100. if(QuestFrame:IsVisible()) then
  101. if(TI_gossipclosed) then
  102. TI_debug("resetting pointers");
  103. TI_gossipclosed = false;
  104. TI_ResetPointers();
  105. end
  106. TI_HandleGossipWindow("q");
  107. end
  108. end
  109. function TI_EventHandlers:GOSSIP_SHOW ()
  110. TI_debug("Gossip Show");
  111. if(GossipFrame:IsVisible()) then
  112. TI_AttachFrameToGossip(GossipFrame);
  113. if(TI_gossipclosed) then
  114. TI_debug("resetting pointers");
  115. TI_gossipclosed = false;
  116. TI_ResetPointers();
  117. end
  118. TI_HandleGossipWindow("g");
  119. end
  120. end
  121. function TI_EventHandlers:GOSSIP_CLOSED ()
  122. TI_debug("Gossip Closed");
  123. if(not GossipFrame:IsVisible()) then
  124. TI_DetachFrame();
  125. TI_gossipclosed = true;
  126. end;
  127. end
  128. function TI_EventHandlers:QUEST_COMPLETE ()
  129. TI_debug("Quest Complete");
  130. if(TI_ShouldTakeAction() and TI_IsNPCOn(UnitName("npc"), "activequest")) then
  131. if(not (GetNumQuestChoices() > 1)) then
  132. GetQuestReward(1);
  133. end
  134. end
  135. TI_ResetPointers();
  136. end
  137. function TI_EventHandlers:QUEST_PROGRESS ()
  138. TI_debug("Quest Progress");
  139. TI_gossipclosed = false;
  140. TI_lastquestframe = "progress";
  141. TI_HandleQuestProgress();
  142. end
  143. function TI_EventHandlers:QUEST_DETAIL ()
  144. TI_debug("Quest Detail");
  145. TI_gossipclosed = false;
  146. if(TI_IsNPCOn(UnitName("npc"), "availquest")) then
  147. TI_HandleAcceptQuest();
  148. end
  149. TI_ResetPointers();
  150. end
  151. function TI_EventHandlers:QUEST_FINISHED ()
  152. TI_debug("Quest Finished");
  153. if(not QuestFrame:IsVisible() and TI_lastquestframe == "greeting") then
  154. TI_debug("looks like the quest frame closed, resetting pointers on next open");
  155. TI_gossipclosed = true;
  156. end
  157. end
  158. function TI_EventHandlers:PLAYER_ENTERING_WORLD ()
  159. TI_message("Turn In loaded");
  160. end
  161. function TI_OnEvent(self, event, ...)
  162. if(event == "VARIABLES_LOADED") then
  163. TI_debug("Variables Loaded");
  164. TI_VarInit();
  165. if(TI_status.state) then
  166. TI_LoadEvents();
  167. end
  168. else
  169. TI_EventHandlers[event]();
  170. end
  171. end
  172. function TI_LoadEvents()
  173. for k,v in pairs(TI_EventHandlers) do
  174. TurnIn:RegisterEvent(k);
  175. end
  176. end
  177. function TI_UnloadEvents()
  178. for k,v in pairs(TI_EventHandlers) do
  179. TurnIn:UnregisterEvent(k);
  180. end
  181. end
  182. --
  183. -- Pointers
  184. -- Keeping track of gossip/quest frame state between event handlers
  185. --
  186. function TI_ResetPointers()
  187. TI_activenumber = 1;
  188. TI_availnumber = 1;
  189. TI_specnum = 0;
  190. end
  191. --
  192. -- Defaults loading for new NPCs
  193. --
  194. local TI_GossipDefaults = {
  195. availquest = "Available Quests",
  196. activequest = "Active Quests",
  197. gossip = "Gossip",
  198. vendor = "Vendor",
  199. taxi = "Taxi",
  200. trainer = "Trainer",
  201. battlemaster = "Battlemaster",
  202. binder = "Hearthstone Binder",
  203. healer = "Spirit Healer",
  204. banker = "Bank",
  205. workorder = "Work Order"
  206. };
  207. function TI_OptionsInit()
  208. TI_status.options = {};
  209. for k,v in pairs(TI_GossipDefaults) do
  210. local temp = {};
  211. temp.name = v;
  212. temp.type = k;
  213. temp.state = false;
  214. table.insert(TI_status.options, temp);
  215. end
  216. end
  217. function TI_NPCIndexGenerate()
  218. TI_NPCIndex = {};
  219. for k,v in pairs(TI_NPCDB) do
  220. table.insert(TI_NPCIndex, k);
  221. end
  222. table.sort(TI_NPCIndex);
  223. end
  224. --
  225. -- User Interface Handlers
  226. --
  227. function TI_Switch(state)
  228. if(state=="on") then
  229. TI_status.state = true;
  230. TI_LoadEvents();
  231. TI_message("Turn In On");
  232. elseif(state=="off") then
  233. TI_ResetPointers();
  234. TI_status.state = false;
  235. TI_UnloadEvents();
  236. TI_message("Turn In Off");
  237. elseif(state=="toggle") then
  238. if(TI_status.state) then
  239. TI_Switch("off");
  240. else
  241. TI_Switch("on");
  242. end
  243. end
  244. TI_StatusIndicatorUpdate();
  245. end
  246. function TI_ShouldTakeAction()
  247. return not IsShiftKeyDown();
  248. end
  249. function TI_SlashCmdHandler(cmd)
  250. cmdlist = {strsplit(" ", cmd)};
  251. local commands = {
  252. on = function ()
  253. TI_Switch("on");
  254. end,
  255. off = function ()
  256. TI_Switch("off");
  257. end,
  258. toggle = function ()
  259. TI_Switch("toggle");
  260. end,
  261. status = function ()
  262. if(TI_status.state) then
  263. TI_message("Turn In On");
  264. else
  265. TI_message("Turn In Off");
  266. end
  267. end,
  268. window = function ()
  269. InterfaceOptionsFrame_OpenToCategory("Turn In");
  270. end,
  271. config = function ()
  272. InterfaceOptionsFrame_OpenToCategory("Turn In");
  273. end,
  274. recent = function ()
  275. TI_TempNPCListWindow:Show();
  276. end,
  277. debug = function ()
  278. if(TI_status.debugstate) then
  279. TI_status.debugstate = false;
  280. TI_message("debug mode off");
  281. else
  282. TI_status.debugstate = true;
  283. TI_message("debug mode on");
  284. end
  285. end
  286. };
  287. if(commands[cmdlist[1]]) then
  288. commands[cmdlist[1]](cmdlist[2], cmdlist[3], cmdlist[4]);
  289. else
  290. 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");
  291. end
  292. end
  293. function TI_IsNPCOn(npcname, type)
  294. local opton = false;
  295. if(type ~= nil) then
  296. for k,v in pairs(TI_status.options) do
  297. if(v.type == type and v.state == true) then
  298. opton = true;
  299. end
  300. end
  301. else
  302. opton = true;
  303. end
  304. if(TI_NPCDB[npcname] == nil and TI_status.usedefault == true and opton == true) then
  305. TI_debug("case 1");
  306. return true;
  307. elseif(TI_NPCDB[npcname] ~= nil and TI_NPCDB[npcname].state) then
  308. TI_debug("case 2");
  309. return true;
  310. elseif(TI_NPCDB[npcname] ~= nil and TI_status.usedefault == true and not TI_NPCDB[npcname].state and opton == true) then
  311. TI_debug("case 4");
  312. return true;
  313. else
  314. TI_debug("case 3");
  315. return false;
  316. end
  317. end
  318. --
  319. -- NPC state machine functions
  320. --
  321. function TI_HandleAcceptQuest()
  322. if(TI_ShouldTakeAction()) then
  323. QuestDetailAcceptButton_OnClick();
  324. end
  325. end
  326. function TI_HandleQuestProgress()
  327. if(TI_ShouldTakeAction()) then
  328. local questname = GetTitleText();
  329. local npcname = UnitName("npc");
  330. if(QuestFrame:IsVisible()) then
  331. if(TI_NPCDB[npcname]) then
  332. local thisnpc = TI_NPCDB[npcname];
  333. if(thisnpc.state) then
  334. for i,current in ipairs(thisnpc) do
  335. if(current.name == questname and current.state) then
  336. TI_CompleteQuest();
  337. end
  338. end
  339. else
  340. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  341. TI_CompleteQuest();
  342. end
  343. end
  344. else
  345. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  346. TI_CompleteQuest();
  347. end
  348. end
  349. end
  350. end
  351. end
  352. function TI_CompleteQuest()
  353. if(TI_ShouldTakeAction()) then
  354. if(IsQuestCompletable()) then
  355. TI_debug("quest is completable, completeing");
  356. CompleteQuest();
  357. TI_ResetPointers();
  358. else
  359. TI_debug("quest is not completable, declining");
  360. QuestDetailDeclineButton_OnClick();
  361. end
  362. end
  363. end
  364. function TI_GetQuests(type)
  365. local numQuests = (getglobal("GetNum"..type.."Quests"))();
  366. local qfn = getglobal("Get"..type.."Title");
  367. local ret = {};
  368. local qname;
  369. local i=1;
  370. for i=1,numQuests do
  371. qname = qfn(i);
  372. ret[i] = {name=qname};
  373. end
  374. return ret;
  375. end
  376. function TI_HandleGossipWindow(gorq)
  377. local SAcQ;
  378. local SAvQ;
  379. local AvailableQuests;
  380. local ActiveQuests;
  381. local GossipOptions;
  382. if(gorq == "g") then
  383. AvailableQuests = TI_TabulateGossipAvailableQuests(GetGossipAvailableQuests());
  384. ActiveQuests = TI_TabulateGossipActiveQuests(GetGossipActiveQuests());
  385. GossipOptions = TI_TabulateGossipOptions(GetGossipOptions());
  386. SAcQ = SelectGossipActiveQuest;
  387. SAvQ = SelectGossipAvailableQuest;
  388. elseif(gorq == "q") then
  389. AvailableQuests = TI_GetQuests("Available");
  390. ActiveQuests = TI_GetQuests("Active");
  391. GossipOptions = {};
  392. SAcQ=SelectActiveQuest;
  393. SAvQ=SelectAvailableQuest;
  394. end
  395. local ListEntry = {};
  396. for i,v in ipairs(AvailableQuests) do
  397. local x={};
  398. x.name = v.name;
  399. x.gorq = gorq;
  400. x.args = i;
  401. x.type = "availquest";
  402. x.icon = v.icon;
  403. x.state = false;
  404. table.insert(ListEntry, x);
  405. end
  406. for i,v in ipairs(ActiveQuests) do
  407. local x={};
  408. x.name = v.name;
  409. x.gorq = gorq;
  410. x.args = i;
  411. x.type = "activequest";
  412. x.icon = v.icon;
  413. x.state = false;
  414. table.insert(ListEntry, x);
  415. end
  416. for i,v in ipairs(GossipOptions) do
  417. local x={};
  418. x.name = v.name;
  419. x.gorq = gorq;
  420. x.args = i;
  421. x.type = v.type;
  422. x.state = false;
  423. table.insert(ListEntry, x);
  424. end
  425. ListEntry.state = false;
  426. local TotalOptions = #AvailableQuests+#ActiveQuests+#GossipOptions;
  427. if(TotalOptions < 1) then
  428. return;
  429. end
  430. local npcname = UnitName("npc");
  431. TI_AddNPCToTempList(npcname, ListEntry);
  432. if(TI_status.autoadd and (not TI_NPCDB[npcname])) then
  433. TI_debug("autoadd on, adding this NPC", TI_status.autoadd, TI_NPCDB[npcname]);
  434. TI_AddNPCToList(ListEntry, npcname);
  435. end
  436. -- If a NPC is in the Database but a new dialog option has appeared (new daily/completed quest) then add it to the DB
  437. if (TI_NPCDB[npcname]) then
  438. for k1, v1 in ipairs(ListEntry) do
  439. local found = false;
  440. for k2, v2 in ipairs(TI_NPCDB[npcname]) do
  441. if (v2.type == v1.type and v2.name == v1.name) then
  442. found = true;
  443. end
  444. end
  445. if (not found) then
  446. table.insert(TI_NPCDB[npcname], v1)
  447. TI_PopulateOptions("npclist updated");
  448. end
  449. end
  450. end
  451. if(TI_availnumber > TotalOptions or TI_activenumber > TotalOptions) then
  452. TI_ResetPointers();
  453. return;
  454. end
  455. if(not TI_ShouldTakeAction()) then
  456. return;
  457. end
  458. TI_debug(npcname);
  459. if(TI_NPCDB[npcname]) then
  460. local thisnpc = TI_NPCDB[npcname];
  461. if(thisnpc.state) then
  462. TI_debug("npc is active, using his options");
  463. TI_PopulateGossipOptionFrame(thisnpc);
  464. for i1,current in ipairs(thisnpc) do
  465. if (current.state == true) then
  466. TI_debug("Current Quest: "..current.name);
  467. if (TI_specnum == 0 or i1 > TI_specnum) then
  468. TI_specnum = i1;
  469. if (current.type == "availquest") then
  470. for i2,v2 in ipairs(AvailableQuests) do
  471. if (v2.name == current.name) then
  472. TI_debug(i1.."-Available Match Found: "..current.name);
  473. TI_FunctionList[current.gorq]["availquest"](i2);
  474. return;
  475. end
  476. end
  477. elseif (current.type == "activequest") then
  478. for i2,v2 in ipairs(ActiveQuests) do
  479. if (v2.name == current.name) then
  480. TI_debug(i1.."-Active Match Found: "..current.name..", "..current.type);
  481. TI_FunctionList[current.gorq]["activequest"](i2);
  482. return;
  483. end
  484. end
  485. else
  486. for i2,v2 in ipairs(GossipOptions) do
  487. if (v2.name == current.name) then
  488. TI_debug(i1.."-Gossip Match Found: "..current.name..", "..current.type);
  489. SelectGossipOption(i2);
  490. return;
  491. end
  492. end
  493. end
  494. end
  495. end
  496. end
  497. return;
  498. else
  499. TI_debug("npc in list, but not active");
  500. end
  501. else
  502. TI_debug("npc not in list");
  503. end
  504. if(TI_status.usedefault == false) then
  505. TI_debug("npc not in list, default set to off, returning.");
  506. return;
  507. end;
  508. TI_debug("using default config");
  509. TI_PopulateGossipOptionFrame(TI_status.options);
  510. for i,current in ipairs(TI_status.options) do
  511. if(current.state) then
  512. if(current.type == "availquest" and #AvailableQuests > 0 and TI_availnumber <= #AvailableQuests) then
  513. TI_availnumber = TI_availnumber + 1;
  514. SAvQ(TI_availnumber-1);
  515. TI_debug("Selecting Available Quest ".. TI_availnumber-1);
  516. return;
  517. elseif(current.type == "activequest" and #ActiveQuests > 0 and TI_activenumber <= #ActiveQuests) then
  518. TI_activenumber = TI_activenumber + 1;
  519. SAcQ(TI_activenumber-1);
  520. TI_debug("Selecting Active Quest ".. TI_activenumber-1);
  521. return;
  522. elseif(#GossipOptions > 0) then
  523. for j,val in ipairs(GossipOptions) do
  524. if(val.type == current.type) then
  525. TI_ResetPointers();
  526. SelectGossipOption(j);
  527. return;
  528. end
  529. end
  530. end
  531. end
  532. end
  533. end
  534. function TI_AddNPCToList(OptList, npcname, confirminquestion)
  535. if (npcname == nil) then
  536. npcname = UnitName("npc");
  537. end
  538. if(#OptList > 0) then
  539. if(TI_NPCDB[npcname] == nil) then
  540. TI_NPCDB[npcname] = TI_copyTable(OptList);
  541. table.insert(TI_NPCIndex, npcname);
  542. table.sort(TI_NPCIndex);
  543. TI_PopulateOptions("npclist updated");
  544. elseif(confirminquestion == true) then
  545. TI_NPCDB[npcname] = TI_copyTable(OptList);
  546. TI_PopulateOptions("npclist updated");
  547. else
  548. TI_NPCInQuestion = {name=npcname, list=OptList};
  549. StaticPopup_Show("TI_NPCINQUESTION", npcname);
  550. end
  551. end
  552. end
  553. function TI_AddNPCToTempList(name, list)
  554. local temp = {};
  555. temp.name = name;
  556. temp.list = list;
  557. local subZone = GetSubZoneText();
  558. local realZone = GetRealZoneText();
  559. if(subZone == "") then
  560. temp.location = realZone;
  561. else
  562. temp.location = subZone .. ", " .. realZone;
  563. end
  564. table.insert(TI_TempNPCList, 1, temp);
  565. if(#TI_TempNPCList > TI_TempNPCListMaxSize) then
  566. table.remove(TI_TempNPCList, TI_TempNPCListMaxSize);
  567. end
  568. TI_TempNPCListUpdate();
  569. end
  570. function TI_DeleteTempNPCIndex(index)
  571. table.remove(TI_TempNPCList, index);
  572. TI_TempNPCListUpdate();
  573. end
  574. function TI_AddTempNPCIndex(index)
  575. TI_AddNPCToList(TI_TempNPCList[index].list, TI_TempNPCList[index].name);
  576. end
  577. function TI_DeleteNPC(index)
  578. local name = TI_NPCIndex[index];
  579. table.remove(TI_NPCIndex, index);
  580. TI_NPCDB[name] = nil;
  581. end
  582. function TI_StripDescriptors(...)
  583. local x = {};
  584. local arg = {...};
  585. for i=1, #arg, 2 do
  586. table.insert(x,arg[i]);
  587. end
  588. return x;
  589. end
  590. function TI_TabulateGossipOptions(...)
  591. local x = {};
  592. local arg = {...};
  593. for i=1, #arg, 2 do
  594. local temp = {};
  595. temp.name = arg[i];
  596. temp.type = arg[i+1];
  597. table.insert(x, temp);
  598. end
  599. return x;
  600. end
  601. function TI_TabulateGossipAvailableQuests(...)
  602. local x = {};
  603. for i=1, select("#", ...), 7 do
  604. local temp = {};
  605. temp.name = select(i, ...);
  606. local isTrivial = select(i+2, ...);
  607. local isDaily = select(i+3, ...);
  608. local isRepeatable = select(i+4, ...);
  609. local isLegendary = select(i+5, ...);
  610. local isIgnored = select(i+6, ...);
  611. if ( isDaily ) then
  612. temp.icon = "Interface\\GossipFrame\\DailyQuestIcon";
  613. elseif ( isRepeatable ) then
  614. temp.icon = "Interface\\GossipFrame\\DailyActiveQuestIcon";
  615. elseif ( isLegendary ) then
  616. temp.icon = "Interface\\GossipFrame\\AvailableLegendaryQuestIcon";
  617. else
  618. temp.icon = "Interface\\GossipFrame\\AvailableQuestIcon";
  619. end
  620. table.insert(x, temp);
  621. end
  622. return x;
  623. end
  624. function TI_TabulateGossipActiveQuests(...)
  625. local x = {};
  626. for i=1, select("#", ...), 6 do
  627. local temp = {};
  628. temp.name = select(i, ...);
  629. local isComplete = select(i+3, ...);
  630. local isLegendary = select(i+4, ...);
  631. if(isComplete) then
  632. if(isLegendary) then
  633. temp.icon = "Interface\\GossipFrame\\ActiveLegendaryQuestIcon";
  634. else
  635. temp.icon = "Interface\\GossipFrame\\ActiveQuestIcon";
  636. end
  637. else
  638. temp.icon = "Interface\\GossipFrame\\IncompleteQuestIcon";
  639. end
  640. table.insert(x, temp);
  641. end
  642. return x;
  643. end
  644. --[[this function stolen from WhisperCast by Sarris, whom I love dearly for his contribution to Paladins everywhere.
  645. ]]
  646. function TI_copyTable( src )
  647. local copy = {}
  648. for k1,v1 in pairs(src) do
  649. if ( type(v1) == "table" ) then
  650. copy[k1]=TI_copyTable(v1)
  651. else
  652. copy[k1]=v1
  653. end
  654. end
  655. return copy
  656. end
  657. function toggle(arg)
  658. return not arg;
  659. end