Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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