View Single Post
05/19/23, 10:49 AM   #1
sinnereso
AddOn Author - Click to view addons
Join Date: Oct 2022
Posts: 247
Question tables and string.find help

hey guys,

Im messing around with tables for a new feature mostly to understand these better and I hit a wall. I keep getting nil as a returned value and I cant see why.

Code:
function MyAddon.FakeFunction()
     MyAddon.savedVariables.autoMetSwap = "Master Gatherer"
     local swapSkill = MyAddon.FindChampionSwapSkill()
     df(tostring(swapSkill))
end

function MyAddon.FindChampionSwapSkill()
	--/script  df(GetChampionSkillName(number))
	local championSkills = {
		["Master Gatherer"] = 78,
		["Treasure Hunter"] = 79,
		["Gifted Rider"] = 92,
		["Homemaker"] = 91,
		["Cutpurse's Art"] = 90,
		["Infamous"] = 77,
		["Reel Technique"] = 88,
		["Angler's Instincts"] = 89,
		["Steed's Blessing"] = 66,
		["Sustaining Shadows"] = 65,
	}
	for skillName, skillID in ipairs(championSkills) do
		if string.find(MyAddon.savedVariables.autoMetSwap, skillName, 1, true) ~= nil then
			return skillID
		end
	end
end
I'm wanting the function to return the skillID into the swapSkill variable at the top but its returning nill nomatter what I do.

Last edited by sinnereso : 05/19/23 at 10:55 AM.
  Reply With Quote