Skip to content

Lua error when interacting with NPCs inside instances #92

Description

@Cryzer

Lua error when interacting with NPCs inside instances

Describe the bug

I'm getting a Lua error from Interaction when interacting with an NPC inside an instance.

The issue appears to occur only inside instances. I cannot reproduce the error when interacting with NPCs in the open world.

The error points to Dialog_Script.lua:502, where the addon retrieves the NPC gender using UnitSex("npc") and then compares the returned value against numeric values.

The relevant code is:

local gender = UnitSex("npc")
local voice =
    NS.Variables.Style_IsEmote and addon.Database.DB_GLOBAL.profile.INT_TTS_EMOTE_VOICE or
    gender == 3 and addon.Database.DB_GLOBAL.profile.INT_TTS_VOICE_02 or
    gender == 2 and addon.Database.DB_GLOBAL.profile.INT_TTS_VOICE_01 or
    gender == 1 and addon.Database.DB_GLOBAL.profile.INT_TTS_VOICE

Inside instances, UnitSex("npc") appears to return a Secret Value. The subsequent comparisons (gender == 3, gender == 2, gender == 1) then cause the Lua error.

Steps to reproduce

  1. Enter an instance.
  2. Make sure Text to Speech is disabled in the Interaction addon settings.
  3. Interact with an NPC that opens a gossip/dialog window.
  4. The Interaction dialog starts to initialize.
  5. A Lua error is generated.
  6. The panel does not open.

The issue appears to be specific to NPC interactions inside instances.

Expected behavior

The NPC dialog panel should open normally without generating a Lua error.

Actual behavior

When interacting with the NPC, the game plays the sound indicating that the interaction/dialog panel should open, but the panel itself does not appear.

A Lua error is generated during the dialog initialization, and the interaction does not proceed.

Notably, Text to Speech is disabled in the Interaction addon settings when the error occurs.

Lua error

1x ...re/Interaction/Modules/Dialog/Core/Dialog_Script.lua:502: attempt to compare local 'gender' (a secret number value, while execution tainted by 'Interaction')
[Interaction/Code/Modules/Core/Interaction/Modules/Dialog/Core/Dialog_Script.lua]:502: in function 'SetLineToIndex'
[Interaction/Code/Modules/Core/Interaction/Modules/Dialog/Core/Dialog_Script.lua]:618: in function 'Start'
[Interaction/Code/Modules/Core/Interaction/Modules/Dialog/Core/Dialog_Script.lua]:653: in function 'Init'
[Interaction/Code/Modules/Core/Interaction/Core/Interaction_Script.lua]:139: in function 'func'
[Interaction/Code/Foundation/Core/Utilities/CallbackRegistry.lua]:40: in function 'Trigger'
[Interaction/Code/Modules/Core/Interaction/Core/Interaction_Script.lua]:117: in function 'Start'
[Interaction/Code/Modules/Core/Interaction/Core/Interaction_Script.lua]:255: in function 'StartInteraction'
[Interaction/Code/Modules/Core/Interaction/Core/Interaction_Script.lua]:267: in function <...Modules/Core/Interaction/Core/Interaction_Script.lua:248>

Locals

The relevant locals at the time of the error are:

playQuest=true
playGossip=true
gender=<secret number>
(*temporary)=false
(*temporary)=<secret number>
(*temporary)=true
(*temporary)="attempt to compare local 'gender' (a secret number value, while execution tainted by 'Interaction')"

Relevant code

The error occurs in:

Code/Modules/Core/Interaction/Modules/Dialog/Core/Dialog_Script.lua

The affected section is the TTS voice selection logic:

local gender = UnitSex("npc")
local voice =
    NS.Variables.Style_IsEmote and addon.Database.DB_GLOBAL.profile.INT_TTS_EMOTE_VOICE or
    gender == 3 and addon.Database.DB_GLOBAL.profile.INT_TTS_VOICE_02 or
    gender == 2 and addon.Database.DB_GLOBAL.profile.INT_TTS_VOICE_01 or
    gender == 1 and addon.Database.DB_GLOBAL.profile.INT_TTS_VOICE

It appears that UnitSex("npc") can return a Secret Value when the NPC is inside an instance, making the direct comparisons against 1, 2, and 3 invalid.

An additional observation is that Text to Speech is disabled in the addon settings when the error occurs, so the TTS functionality is not intentionally being used at the time of the error.

Environment

  • Interaction version: 0.3.5
  • World of Warcraft patch: 12.1.0
  • Location: Inside instances
  • Affected interaction: NPC gossip/dialog
  • Text to Speech: Disabled

Additional information

  • The error occurs while opening an NPC gossip/dialog.
  • The issue appears to be limited to NPCs inside instances.
  • NPC interactions outside instances do not appear to trigger this error.
  • The game plays the interaction sound, indicating that the dialog is being triggered, but the Interaction panel does not appear.
  • Text to Speech is disabled in the Interaction addon settings when the error occurs.
  • The stack trace points directly to the TTS gender detection code.
  • The error prevents the dialog from being initialized correctly.
  • The error occurs with playGossip=true and playQuest=true.

The fact that the error occurs even when Text to Speech is disabled may indicate that the UnitSex("npc") call and the subsequent gender comparisons are being evaluated regardless of the TTS setting.

This may be related to WoW's Secret Value restrictions and changes to how UnitSex() behaves for NPCs in instances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions