peti446 / SwitchSwitch

This addon allows you to automatically change talents with a couple of clicks. No more need to remember all these talents. Also, you can configure it to prompt you to change based on the type of instance you joined.

Home Page:https://wow.curseforge.com/projects/switchswitch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SwitchSwitch.lua:61: table index is nil

Hayato2846 opened this issue · comments

Hey!

Well, I still got the same error mentioned in the closed Issue. It seems like the functions EnsureTablentSpecTableExits and GetCurrentProfilesTable were called while in a Loading Screen and Player Spec Info returns nil. I changed this by myself in your functions so that they're a little bit more robust.

Would be super cool if you can check it out :)

function addon:EnsureTablentSpecTableExits()
	local playerClass = select(3, UnitClass("player"));
	local playerSpec = select(1,GetSpecializationInfo(GetSpecialization()));
    addon:EnsureTalentClassTableExits()
	if (playerClass and playerSpec) then
		if(addon.sv.Talents.Profiles[playerClass][playerSpec] == nil) then
			addon.sv.Talents.Profiles[playerClass][playerSpec] = {}
		end
	end
end


function addon:GetCurrentProfilesTable()
	local playerClass = select(3, UnitClass("player"));
	local playerSpec = select(1,GetSpecializationInfo(GetSpecialization()));
	local playerTable = {}
	
    addon:EnsureTablentSpecTableExits()
	
	if (playerClass and playerSpec) then
		playerTable = addon.sv.Talents.Profiles[playerClass][playerSpec];
	end
	
    return playerTable
end

Thanks in advance!

Thanks for reporting it and even providing a solution! It is strange that it is still calling it during the loading screen, will have a deeper look but in the meantime will implement the changes you mentioned :)