WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Skip "phrase" from NPC (https://www.wowinterface.com/forums/showthread.php?t=59837)

Hubb777 03-27-24 09:59 PM

Skip "phrase" from NPC
 
Hi all. I plan to make it possible to skip some dialogue when talking to NPCs. But there is an error in the code. Please tell me the solution.

Lua Code:
  1. local addonName = ...
  2. local AutoSelectGossip = {
  3.     [48598] = true,
  4.     [109275] = true,
  5. };
  6.  
  7. local function IsAutoSelectOption(gossipOptionID)
  8.     return gossipOptionID and AutoSelectGossip[gossipOptionID] == true
  9. end
  10. addon.IsAutoSelectOption = IsAutoSelectOption;

Fizzlemizz 03-27-24 11:31 PM

Lua Code:
  1. local addonName = ...
  2. local AutoSelectGossip = {
  3.     [48598] = true,
  4.     [109275] = true,
  5. };
  6.      
  7. local function IsAutoSelectOption(gossipOptionID)
  8.     return gossipOptionID and AutoSelectGossip[gossipOptionID] == true
  9. end
  10. addon.IsAutoSelectOption = IsAutoSelectOption;
You haven't defined addon. My guess is it is suppsed to be your addon's private table (NameSpace) so:

Lua Code:
  1. local addonName, addon = ...
  2. local AutoSelectGossip = {
  3.     [48598] = true,
  4.     [109275] = true,
  5. };
  6.      
  7. local function IsAutoSelectOption(gossipOptionID)
  8.     return gossipOptionID and AutoSelectGossip[gossipOptionID] == true
  9. end
  10. addon.IsAutoSelectOption = IsAutoSelectOption;

Hubb777 03-27-24 11:53 PM

Hello. Yes the error is gone. But the code doesn't work. NPC dialogue is no longer skipped.

This is the dialog ID
Lua Code:
  1. local AutoSelectGossip = {
  2.     [48598] = true,
  3.     [109275] = true,
  4. };

Or should the code be like this? Then how to insert several dialogues from different NPCs there?

Lua Code:
  1. local function EL_OnGossipShow(self, event, ...)
  2.     if ENABLE_AUTO_REPORT and UnitName("npc") == HUBB then
  3.         if GossipFrame and GossipFrame:IsShown() then
  4.             local options = C_GossipInfo.GetOptions();
  5.             if options and options[1] and options[1].gossipOptionID == 109275 then
  6.                 C_GossipInfo.SelectOption(109275);
  7.                 return
  8.             end
  9.         end
  10.     end
  11. end

sirpucna 03-28-24 06:30 AM

i got ChatGPT to whip this up for me a bit ago.

Lua Code:
  1. --/dump C_GossipInfo.GetOptions()
  2.         --use above on every dialog to capture gossip IDs
  3.         local NPC_LIST = {
  4.             ["Katy Stampwhistle"] = {48598},
  5.             ["Haephesta"] = {56395, 55039}, --selects option 1, then 3
  6.         }
  7.  
  8.         local AutoGossip = CreateFrame("Frame")
  9.         function AutoGossip:OnEvent(_, type)
  10.             if IsShiftKeyDown() then return end
  11.             if type ~= Enum.PlayerInteractionType.Gossip then return end
  12.             local npcName = GossipFrame.TitleContainer.TitleText:GetText()
  13.             if not npcName then return end
  14.             local gossips = NPC_LIST[npcName]
  15.             if not gossips then return end
  16.             local options = C_GossipInfo.GetOptions()
  17.             if not options then return end
  18.             for _, option in ipairs(options) do
  19.                 if tContains(gossips, option.gossipOptionID) then
  20.                     C_GossipInfo.SelectOption(option.gossipOptionID)
  21.                     return
  22.                 end
  23.             end
  24.         end
  25.  
  26.         AutoGossip:SetScript("OnEvent", AutoGossip.OnEvent)
  27.         AutoGossip:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_SHOW")

Hubb777 03-29-24 12:40 AM

Thanks it worked. And thanks for the idea to use AI.


All times are GMT -6. The time now is 11:55 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI