Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

TurnIn.lua 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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_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. };
  206. function TI_OptionsInit()
  207. TI_status.options = {};
  208. for k,v in pairs(TI_GossipDefaults) do
  209. local temp = {};
  210. temp.name = v;
  211. temp.type = k;
  212. temp.state = false;
  213. table.insert(TI_status.options, temp);
  214. end
  215. end
  216. function TI_NPCIndexGenerate()
  217. TI_NPCIndex = {};
  218. for k,v in pairs(TI_NPCDB) do
  219. table.insert(TI_NPCIndex, k);
  220. end
  221. table.sort(TI_NPCIndex);
  222. end
  223. --
  224. -- User Interface Handlers
  225. --
  226. function TI_Switch(state)
  227. if(state=="on") then
  228. TI_status.state = true;
  229. TI_LoadEvents();
  230. TI_message("Turn In On");
  231. elseif(state=="off") then
  232. TI_ResetPointers();
  233. TI_status.state = false;
  234. TI_UnloadEvents();
  235. TI_message("Turn In Off");
  236. elseif(state=="toggle") then
  237. if(TI_status.state) then
  238. TI_Switch("off");
  239. else
  240. TI_Switch("on");
  241. end
  242. end
  243. TI_StatusIndicatorUpdate();
  244. end
  245. function TI_ShouldTakeAction()
  246. return not IsShiftKeyDown();
  247. end
  248. function TI_SlashCmdHandler(cmd)
  249. cmdlist = {strsplit(" ", cmd)};
  250. local commands = {
  251. on = function ()
  252. TI_Switch("on");
  253. end,
  254. off = function ()
  255. TI_Switch("off");
  256. end,
  257. toggle = function ()
  258. TI_Switch("toggle");
  259. end,
  260. status = function ()
  261. if(TI_status.state) then
  262. TI_message("Turn In On");
  263. else
  264. TI_message("Turn In Off");
  265. end
  266. end,
  267. window = function ()
  268. InterfaceOptionsFrame_OpenToCategory("Turn In");
  269. end,
  270. config = function ()
  271. InterfaceOptionsFrame_OpenToCategory("Turn In");
  272. end,
  273. recent = function ()
  274. TI_TempNPCListWindow:Show();
  275. end,
  276. debug = function ()
  277. if(TI_status.debugstate) then
  278. TI_status.debugstate = false;
  279. TI_message("debug mode off");
  280. else
  281. TI_status.debugstate = true;
  282. TI_message("debug mode on");
  283. end
  284. end
  285. };
  286. if(commands[cmdlist[1]]) then
  287. commands[cmdlist[1]](cmdlist[2], cmdlist[3], cmdlist[4]);
  288. else
  289. 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");
  290. end
  291. end
  292. function TI_IsNPCOn(npcname, type)
  293. local opton = false;
  294. if(type ~= nil) then
  295. for k,v in pairs(TI_status.options) do
  296. if(v.type == type and v.state == true) then
  297. opton = true;
  298. end
  299. end
  300. else
  301. opton = true;
  302. end
  303. if(TI_NPCDB[npcname] == nil and TI_status.usedefault == true and opton == true) then
  304. TI_debug("case 1");
  305. return true;
  306. elseif(TI_NPCDB[npcname] ~= nil and TI_NPCDB[npcname].state) then
  307. TI_debug("case 2");
  308. return true;
  309. elseif(TI_NPCDB[npcname] ~= nil and TI_status.usedefault == true and not TI_NPCDB[npcname].state and opton == true) then
  310. TI_debug("case 4");
  311. return true;
  312. else
  313. TI_debug("case 3");
  314. return false;
  315. end
  316. end
  317. --
  318. -- NPC state machine functions
  319. --
  320. function TI_HandleAcceptQuest()
  321. if(TI_ShouldTakeAction()) then
  322. QuestDetailAcceptButton_OnClick();
  323. end
  324. end
  325. function TI_HandleQuestProgress()
  326. if(TI_ShouldTakeAction()) then
  327. local questname = GetTitleText();
  328. local npcname = UnitName("npc");
  329. if(QuestFrame:IsVisible()) then
  330. if(TI_NPCDB[npcname]) then
  331. local thisnpc = TI_NPCDB[npcname];
  332. if(thisnpc.state) then
  333. for i,current in ipairs(thisnpc) do
  334. if(current.name == questname and current.state) then
  335. TI_CompleteQuest();
  336. end
  337. end
  338. else
  339. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  340. TI_CompleteQuest();
  341. end
  342. end
  343. else
  344. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  345. TI_CompleteQuest();
  346. end
  347. end
  348. end
  349. end
  350. end
  351. function TI_CompleteQuest()
  352. if(TI_ShouldTakeAction()) then
  353. if(IsQuestCompletable()) then
  354. TI_debug("quest is completable, completeing");
  355. CompleteQuest();
  356. TI_ResetPointers();
  357. else
  358. TI_debug("quest is not completable, declining");
  359. QuestDetailDeclineButton_OnClick();
  360. end
  361. end
  362. end
  363. function TI_GetQuests(type)
  364. local numQuests = (getglobal("GetNum"..type.."Quests"))();
  365. local qfn = getglobal("Get"..type.."Title");
  366. local ret = {};
  367. local qname;
  368. local i=1;
  369. for i=1,numQuests do
  370. qname = qfn(i);
  371. ret[i] = {name=qname};
  372. end
  373. return ret;
  374. end
  375. function TI_HandleGossipWindow(gorq)
  376. local SAcQ;
  377. local SAvQ;
  378. local AvailableQuests;
  379. local ActiveQuests;
  380. local GossipOptions;
  381. if(gorq == "g") then
  382. AvailableQuests = TI_TabulateGossipAvailableQuests(GetGossipAvailableQuests());
  383. ActiveQuests = TI_TabulateGossipActiveQuests(GetGossipActiveQuests());
  384. GossipOptions = TI_TabulateGossipOptions(GetGossipOptions());
  385. SAcQ = SelectGossipActiveQuest;
  386. SAvQ = SelectGossipAvailableQuest;
  387. elseif(gorq == "q") then
  388. AvailableQuests = TI_GetQuests("Available");
  389. ActiveQuests = TI_GetQuests("Active");
  390. GossipOptions = {};
  391. SAcQ=SelectActiveQuest;
  392. SAvQ=SelectAvailableQuest;
  393. end
  394. local ListEntry = {};
  395. for i,v in ipairs(AvailableQuests) do
  396. local x={};
  397. x.name = v.name;
  398. x.gorq = gorq;
  399. x.args = i;
  400. x.type = "availquest";
  401. x.icon = v.icon;
  402. x.state = false;
  403. table.insert(ListEntry, x);
  404. end
  405. for i,v in ipairs(ActiveQuests) do
  406. local x={};
  407. x.name = v.name;
  408. x.gorq = gorq;
  409. x.args = i;
  410. x.type = "activequest";
  411. x.icon = v.icon;
  412. x.state = false;
  413. table.insert(ListEntry, x);
  414. end
  415. for i,v in ipairs(GossipOptions) do
  416. local x={};
  417. x.name = v.name;
  418. x.gorq = gorq;
  419. x.args = i;
  420. x.type = v.type;
  421. x.state = false;
  422. table.insert(ListEntry, x);
  423. end
  424. ListEntry.state = false;
  425. local TotalOptions = #AvailableQuests+#ActiveQuests+#GossipOptions;
  426. if(TotalOptions < 1) then
  427. return;
  428. end
  429. local npcname = UnitName("npc");
  430. TI_AddNPCToTempList(npcname, ListEntry);
  431. if(TI_status.autoadd and (not TI_NPCDB[npcname])) then
  432. TI_debug("autoadd on, adding this NPC", TI_status.autoadd, TI_NPCDB[npcname]);
  433. TI_AddNPCToList(ListEntry, npcname);
  434. end
  435. -- If a NPC is in the Database but a new dialog option has appeared (new daily/completed quest) then add it to the DB
  436. if (TI_NPCDB[npcname]) then
  437. for k1, v1 in ipairs(ListEntry) do
  438. local found = false;
  439. for k2, v2 in ipairs(TI_NPCDB[npcname]) do
  440. if (v2.type == v1.type and v2.name == v1.name) then
  441. found = true;
  442. end
  443. end
  444. if (not found) then
  445. table.insert(TI_NPCDB[npcname], v1)
  446. TI_PopulateOptions("npclist updated");
  447. end
  448. end
  449. end
  450. if(TI_availnumber > TotalOptions or TI_activenumber > TotalOptions) then
  451. TI_ResetPointers();
  452. return;
  453. end
  454. if(not TI_ShouldTakeAction()) then
  455. return;
  456. end
  457. TI_debug(npcname);
  458. if(TI_NPCDB[npcname]) then
  459. local thisnpc = TI_NPCDB[npcname];
  460. if(thisnpc.state) then
  461. TI_debug("npc is active, using his options");
  462. TI_PopulateGossipOptionFrame(thisnpc);
  463. for i1,current in ipairs(thisnpc) do
  464. if (current.state == true) then
  465. TI_debug("Current Quest: "..current.name);
  466. if (TI_specnum == 0 or i1 > TI_specnum) then
  467. TI_specnum = i1;
  468. if (current.type == "availquest") then
  469. for i2,v2 in ipairs(AvailableQuests) do
  470. if (v2.name == current.name) then
  471. TI_debug(i1.."-Available Match Found: "..current.name);
  472. TI_FunctionList[current.gorq]["availquest"](i2);
  473. return;
  474. end
  475. end
  476. elseif (current.type == "activequest") then
  477. for i2,v2 in ipairs(ActiveQuests) do
  478. if (v2.name == current.name) then
  479. TI_debug(i1.."-Active Match Found: "..current.name..", "..current.type);
  480. TI_FunctionList[current.gorq]["activequest"](i2);
  481. return;
  482. end
  483. end
  484. else
  485. for i2,v2 in ipairs(GossipOptions) do
  486. if (v2.name == current.name) then
  487. TI_debug(i1.."-Gossip Match Found: "..current.name..", "..current.type);
  488. SelectGossipOption(i2);
  489. return;
  490. end
  491. end
  492. end
  493. end
  494. end
  495. end
  496. return;
  497. else
  498. TI_debug("npc in list, but not active");
  499. end
  500. else
  501. TI_debug("npc not in list");
  502. end
  503. if(TI_status.usedefault == false) then
  504. TI_debug("npc not in list, default set to off, returning.");
  505. return;
  506. end;
  507. TI_debug("using default config");
  508. TI_PopulateGossipOptionFrame(TI_status.options);
  509. for i,current in ipairs(TI_status.options) do
  510. if(current.state) then
  511. if(current.type == "availquest" and #AvailableQuests > 0 and TI_availnumber <= #AvailableQuests) then
  512. TI_availnumber = TI_availnumber + 1;
  513. SAvQ(TI_availnumber-1);
  514. TI_debug("Selecting Available Quest ".. TI_availnumber-1);
  515. return;
  516. elseif(current.type == "activequest" and #ActiveQuests > 0 and TI_activenumber <= #ActiveQuests) then
  517. TI_activenumber = TI_activenumber + 1;
  518. SAcQ(TI_activenumber-1);
  519. TI_debug("Selecting Active Quest ".. TI_activenumber-1);
  520. return;
  521. elseif(#GossipOptions > 0) then
  522. for j,val in ipairs(GossipOptions) do
  523. if(val.type == current.type) then
  524. TI_ResetPointers();
  525. SelectGossipOption(j);
  526. return;
  527. end
  528. end
  529. end
  530. end
  531. end
  532. end
  533. function TI_AddNPCToList(OptList, npcname, confirminquestion)
  534. if (npcname == nil) then
  535. npcname = UnitName("npc");
  536. end
  537. if(#OptList > 0) then
  538. if(TI_NPCDB[npcname] == nil) then
  539. TI_NPCDB[npcname] = TI_copyTable(OptList);
  540. table.insert(TI_NPCIndex, npcname);
  541. table.sort(TI_NPCIndex);
  542. TI_PopulateOptions("npclist updated");
  543. elseif(confirminquestion == true) then
  544. TI_NPCDB[npcname] = TI_copyTable(OptList);
  545. TI_PopulateOptions("npclist updated");
  546. else
  547. TI_NPCInQuestion = {name=npcname, list=OptList};
  548. StaticPopup_Show("TI_NPCINQUESTION", npcname);
  549. end
  550. end
  551. end
  552. function TI_AddNPCToTempList(name, list)
  553. local temp = {};
  554. temp.name = name;
  555. temp.list = list;
  556. local subZone = GetSubZoneText();
  557. local realZone = GetRealZoneText();
  558. if(subZone == "") then
  559. temp.location = realZone;
  560. else
  561. temp.location = subZone .. ", " .. realZone;
  562. end
  563. table.insert(TI_TempNPCList, 1, temp);
  564. if(#TI_TempNPCList > TI_TempNPCListMaxSize) then
  565. table.remove(TI_TempNPCList, TI_TempNPCListMaxSize);
  566. end
  567. TI_TempNPCListUpdate();
  568. end
  569. function TI_DeleteTempNPCIndex(index)
  570. table.remove(TI_TempNPCList, index);
  571. TI_TempNPCListUpdate();
  572. end
  573. function TI_AddTempNPCIndex(index)
  574. TI_AddNPCToList(TI_TempNPCList[index].list, TI_TempNPCList[index].name);
  575. end
  576. function TI_DeleteNPC(index)
  577. local name = TI_NPCIndex[index];
  578. table.remove(TI_NPCIndex, index);
  579. TI_NPCDB[name] = nil;
  580. end
  581. function TI_StripDescriptors(...)
  582. local x = {};
  583. local arg = {...};
  584. for i=1, #arg, 2 do
  585. table.insert(x,arg[i]);
  586. end
  587. return x;
  588. end
  589. function TI_TabulateGossipOptions(...)
  590. local x = {};
  591. local arg = {...};
  592. for i=1, #arg, 2 do
  593. local temp = {};
  594. temp.name = arg[i];
  595. temp.type = arg[i+1];
  596. table.insert(x, temp);
  597. end
  598. return x;
  599. end
  600. function TI_TabulateGossipAvailableQuests(...)
  601. local x = {};
  602. for i=1, select("#", ...), 7 do
  603. local temp = {};
  604. temp.name = select(i, ...);
  605. local isTrivial = select(i+2, ...);
  606. local isDaily = select(i+3, ...);
  607. local isRepeatable = select(i+4, ...);
  608. local isLegendary = select(i+5, ...);
  609. local isIgnored = select(i+6, ...);
  610. if ( isDaily ) then
  611. temp.icon = "Interface\\GossipFrame\\DailyQuestIcon";
  612. elseif ( isRepeatable ) then
  613. temp.icon = "Interface\\GossipFrame\\DailyActiveQuestIcon";
  614. elseif ( isLegendary ) then
  615. temp.icon = "Interface\\GossipFrame\\AvailableLegendaryQuestIcon";
  616. else
  617. temp.icon = "Interface\\GossipFrame\\AvailableQuestIcon";
  618. end
  619. table.insert(x, temp);
  620. end
  621. return x;
  622. end
  623. function TI_TabulateGossipActiveQuests(...)
  624. local x = {};
  625. for i=1, select("#", ...), 6 do
  626. local temp = {};
  627. temp.name = select(i, ...);
  628. local isComplete = select(i+3, ...);
  629. local isLegendary = select(i+4, ...);
  630. if(isComplete) then
  631. if(isLegendary) then
  632. temp.icon = "Interface\\GossipFrame\\ActiveLegendaryQuestIcon";
  633. else
  634. temp.icon = "Interface\\GossipFrame\\ActiveQuestIcon";
  635. end
  636. else
  637. temp.icon = "Interface\\GossipFrame\\IncompleteQuestIcon";
  638. end
  639. table.insert(x, temp);
  640. end
  641. return x;
  642. end
  643. --[[this function stolen from WhisperCast by Sarris, whom I love dearly for his contribution to Paladins everywhere.
  644. ]]
  645. function TI_copyTable( src )
  646. local copy = {}
  647. for k1,v1 in pairs(src) do
  648. if ( type(v1) == "table" ) then
  649. copy[k1]=TI_copyTable(v1)
  650. else
  651. copy[k1]=v1
  652. end
  653. end
  654. return copy
  655. end
  656. function toggle(arg)
  657. return not arg;
  658. end