View Single Post
01-01-22, 04:01 PM   #11
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
Here is a complete addon.

Press M to open and close the map.

While the map is open, press left-shift and left-control to go up and down the quests. It starts at the top, so you will need to use left-control to navigate to the first quest. Press tab to repeat the name and number of the quest.

While at a quest, press left-alt to hear the full description slowly, or right-alt to hear the objectives more quickly.

To be clear, you are not actually changing the game's selected quest when you use this code. It is simply navigating its own table. A more advanced version of this would probably integrate with the quest log to actually choose quests.


Lua Code:
  1. local quests = {}
  2. local questSelected = 1
  3.  
  4. local function speakText(spokenMessage, speed)
  5.     C_VoiceChat.StopSpeakingText()
  6.     C_VoiceChat.SpeakText(1, spokenMessage, Enum.VoiceTtsDestination.QueuedLocalPlayback, speed or 5, 100)
  7. end
  8.  
  9. local function readCurrentTitle()
  10.     if quests[questSelected]["isHeader"] then
  11.         speakText(questSelected .. " is a header: " .. quests[questSelected]["title"])
  12.     else
  13.         speakText(questSelected .. " is " .. quests[questSelected]["title"])
  14.     end
  15. end
  16.  
  17. local function readCurrentDescription()
  18.     if quests[questSelected]["isHeader"] then
  19.         speakText("Sorry, that is a header.")
  20.     else
  21.         speakText(quests[questSelected]["title"] .. ": " .. quests[questSelected]["description"], 2)
  22.     end
  23. end
  24.  
  25. local function readCurrentObjectives()
  26.     if quests[questSelected]["isHeader"] then
  27.         speakText("Sorry, that is a header.")
  28.     else
  29.         speakText(quests[questSelected]["title"] .. ": " .. quests[questSelected]["objectives"], 4)
  30.     end
  31. end
  32.  
  33. local function next()
  34.     if questSelected < #quests then
  35.         questSelected = questSelected + 1
  36.     else
  37.         questSelected = 1
  38.     end
  39.     readCurrentTitle()
  40. end
  41.  
  42. local function prev()
  43.     if questSelected > 1 then
  44.         questSelected = questSelected - 1
  45.     else
  46.         questSelected = #quests
  47.     end
  48.     readCurrentTitle()
  49. end
  50.  
  51. local function goto(i)
  52.     if not tonumber(i) then
  53.         i = 1
  54.     elseif i < 1 then
  55.         i = 1
  56.     elseif i > #quests then
  57.         i = #quests
  58.     end
  59.     questSelected = i
  60.     readCurrentTitle()
  61. end
  62.  
  63. local frame = CreateFrame("Frame", nil, QuestMapFrame)
  64.  
  65. frame:RegisterEvent("QUEST_LOG_UPDATE")
  66. frame:SetScript("OnEvent", function(__, event)
  67.     if event == "QUEST_LOG_UPDATE" and not QuestMapFrame.ignoreQuestLogUpdate and QuestMapFrame:IsShown() then
  68.         wipe(quests)
  69.         for i=1, C_QuestLog.GetNumQuestLogEntries() do
  70.             quests[i] = C_QuestLog.GetInfo(i)
  71.             if quests[i]["questID"] > 0 then
  72.                 quests[i]["description"], quests[i]["objectives"] = GetQuestLogQuestText(i)
  73.             end
  74.         end
  75.         if questSelected > #quests then
  76.             questSelected = 1
  77.         end
  78.         readCurrentTitle()
  79.     end
  80. end)
  81.  
  82. frame:EnableKeyboard(true)
  83. frame:SetPropagateKeyboardInput(true)
  84. frame:SetScript("OnKeyDown", function(__, key)
  85.     if key == "LSHIFT" then
  86.         prev()
  87.     elseif key == "LCTRL" then
  88.         next()
  89.     elseif key == "LALT" then
  90.         readCurrentDescription()
  91.     elseif key == "RALT" then
  92.         readCurrentObjectives()
  93.     elseif key == "TAB" then
  94.         readCurrentTitle()
  95.     end
  96. end)


Edit: I wrote mine before you edited your post.
  Reply With Quote