Thread Tools Display Modes
03-27-24, 09:59 PM   #1
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 111
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;
  Reply With Quote
03-27-24, 11:31 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
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;
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
03-27-24, 11:53 PM   #3
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 111
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

Last edited by Hubb777 : 03-28-24 at 12:10 AM.
  Reply With Quote
03-28-24, 06:30 AM   #4
sirpucna
An Aku'mai Servant
Join Date: Nov 2016
Posts: 34
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")
  Reply With Quote
03-29-24, 12:40 AM   #5
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 111
Thanks it worked. And thanks for the idea to use AI.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Skip "phrase" from NPC


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off