Lucid Keystone

Lucid Keystone

9.2k Downloads

Issue with affix preview (both in dungeon and out [preview mode])

TheLostInPlace opened this issue ยท 3 comments

commented

Version: 1.04

Addon List: WeakAuras, GladiusEx, RareScanner, Rarity, ElvUI, ElvUI: Shadow & Light, ProjectAzilroka, Details!, Details!: Avoidable Damage, Lucid Keystones, DBM, BugSack, BugGrabber

Description: I've been running into this issue where upon entering a Mythic+ Dungeon, the Addon errors out completely and stops working properly. This issue also occurs when I try to preview how the timer would look like outside of dungeons and I enable the affix preview options, e.g (Icon-Button).

Error:

1x LucidKeystone\modules\Timer.lua:929: attempt to get length of local 'wAffix' (a nil value)
[string "@LucidKeystone\modules\Timer.lua"]:929: in function `AffixText'
[string "@LucidKeystone\modules\Config.lua"]:1492: in function <LucidKeystone\modules\Config.lua:1489>
[string "=[C]"]: ?
[string "@GladiusEx\libs\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-80.lua"]:51: in function <...nfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.lua:49>
[string "@GladiusEx\libs\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-80.lua"]:846: in function <...nfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.lua:667>
[string "=[C]"]: ?
[string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:72: in function <Ace3\AceGUI-3.0\AceGUI-3.0.lua:70>
[string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:306: in function `Fire'
[string "@Ace3\AceGUI-3.0-41\widgets\AceGUIWidget-DropDown.lua"]:437: in function <...ns\Ace3\AceGUI-3.0\widgets\AceGUIWidget-DropDown.lua:428>
[string "=[C]"]: ?
[string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:72: in function <Ace3\AceGUI-3.0\AceGUI-3.0.lua:70>
[string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:306: in function `Fire'
[string "@Ace3\AceGUI-3.0-41\widgets\AceGUIWidget-DropDown-Items.lua"]:351: in function <...3\AceGUI-3.0\widgets\AceGUIWidget-DropDown-Items.lua:341>

Sometimes it would also spit out this error:

1x LucidKeystone\modules\Timer.lua:929: attempt to get length of local 'wAffix' (a nil value)
[string "@LucidKeystone\modules\Timer.lua"]:929: in function `AffixText'
[string "@LucidKeystone\modules\Config.lua"]:1492: in function <LucidKeystone\modules\Config.lua:1489>
[string "=[C]"]: ?
[string "@WeakAuras\Libs\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-80.lua"]:51: in function <...nfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.lua:49>
[string "@WeakAuras\Libs\AceConfig-3.0-3\AceConfigDialog-3.0\AceConfigDialog-3.0-80.lua"]:846: in function <...nfig-3.0\AceConfigDialog-3.0\AceConfigDialog-3.0.lua:667>
[string "=[C]"]: ?
[string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:72: in function <Ace3\AceGUI-3.0\AceGUI-3.0.lua:70>
[string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:306: in function `Fire'
[string "@Ace3\AceGUI-3.0-41\widgets\AceGUIWidget-DropDown.lua"]:437: in function <...ns\Ace3\AceGUI-3.0\widgets\AceGUIWidget-DropDown.lua:428>
[string "=[C]"]: ?
[string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:72: in function <Ace3\AceGUI-3.0\AceGUI-3.0.lua:70>
[string "@Ace3\AceGUI-3.0\AceGUI-3.0-41.lua"]:306: in function `Fire'
[string "@Ace3\AceGUI-3.0-41\widgets\AceGUIWidget-DropDown-Items.lua"]:351: in function <...3\AceGUI-3.0\widgets\AceGUIWidget-DropDown-Items.lua:341>

I can provide more information as needed.

commented

I've done some meddling around and I think I know why the issue occurs. The API being called C_MythicPlus.GetCurrentAffixes() returns nil when not in Mythic Plus instances. The preview code does not account for this, and as a result, nil is passed to #wAffix. This is obviously not a valid statement. Furthermore, I wrote this test function:

local function isnil(s)
	return s == nil
end

	if isnil(wAffix) then
		print("wAffix returned nil. Defaulting to preview affixes.")
		wAffix = {
		[1]={
			id=9,
			seasonID=0
			},
		[2]={
			id=7,
			seasonID=0
			},
		[3]={
			id=4,
			seasonID=0
			},
		[4]={
			id=121,
			seasonID=0
			}
			}
	end

and inserted it into the

-- Get Affixes 
function Module.Config:AffixText()

section in Timer.lua.
image

This fixes the issue of previewing in the open world, resulting in all of the preview options for affixes to display properly. The test affixes in order are: Tyrannical, Bolstering, Nectoric, and Prideful.
image
image

I'm sure there is a way to detect via the API if the player is NOT in a Mythic Plus instance, and revert to using the preview affixes, I'm just not sure of how to do it as I have never written a WoW addon and thus I am unfamiliar with the API. I hope this helps you narrow down the issue, as your addon is very nice and I would prefer to use it over other keystone addons.

commented

Curiousity got the best of me and I ended up looking at the WoW API and found a method that returns true/false based on whether the player is in an active Mythic Plus instance C_ChallengeMode.IsChallengeModeActive(). Using this newfound knowledge, I think I was able to fix the issue completely. This is the code I used:

-- Get Affixes
function Module.Config:AffixText()
    local f = LucidKeystoneFrame
    local offset = 0
    local wAffix = {}
    local affixTable = {}
	
	if (C_ChallengeMode.IsChallengeModeActive() == true) then
		--print("ChallengeMode returned true.")
		wAffix = C_MythicPlus.GetCurrentAffixes()
	elseif (C_ChallengeMode.IsChallengeModeActive() == false) then
		--print("ChallengeMode returned false.")
		wAffix = {
		[1]={
			id=9,
			seasonID=0
			},
		[2]={
			id=7,
			seasonID=0
			},
		[3]={
			id=4,
			seasonID=0
			},
		[4]={
			id=121,
			seasonID=0
			}
		}
	end

There are probably better ways to write this in a more efficient manner, but this seems to have fixed my issue completely. Feel free to incorporate it as is or re-write it (this is with limited testing, but seems to work thus far).

Edit: Upon further research, I found a different method named C_MythicPlus.IsMythicPlusActive(). Switching over to this instead of C_ChallengeMode.IsChallengeModeActive() might be better in case Blizzard deprecates the ChallengeMode method.

Edit 2: It seems that C_ChallengeMode.IsChallengeModeActive() is not consistent and can still result in wAffix being null prior to starting the key, which bugs out the timer. Using C_MythicPlus.IsMythicPlusActive() seems to be more consistent.

commented

Hey Mate!!

At first sorry for the late respond, I was kinda busy the last days.
So thank you for given me this Issue and the solution of it xD After I took a look over it, it should be one of the best solutions. I will add this code to the Addon in v1.0.6. I just changed some small things, but basically its your code in there.