View Single Post
03/26/23, 04:19 PM   #20
sinnereso
AddOn Author - Click to view addons
Join Date: Oct 2022
Posts: 245
Question

I messed up my save player function somehow this morning cleaning up notes and many unessissary variables or so I thought.

The saved variable is saving correctly.. the DF output is outputting correctly and yet Im getting a nil value error on editing the text field in the setting panel just below it.

Heres what i got setup atm and shud only be a local variable to fix it I would think. Any suggestions would be appreciated. I was soo close to done with this thing.

Code:
--ADDON LOADED--
local category = LibCustomMenu.CATEGORY_LATE--<<< context menu stuff
LibCustomMenu:RegisterGuildRosterContextMenu(MyAddon.AddGGFContext, category)
LibCustomMenu:RegisterFriendsListContextMenu(MyAddon.AddGGFContext, category)
LibCustomMenu:RegisterGroupListContextMenu(MyAddon.AddGGFContext, category)
MyAddon:CreateSettingsWindow()

-- LibAddonMenu SETTINGS PANEL TEXT FIELD --
{
		type = "description",
		text = "Saved Player:  " .. tostring(MyAddon.savedVariables.savedPlayer),
		reference = "MyAddon_SETTINGS_SAVEDPLAYER_TEXT",
		width = "half",
},

------ Save player functions ------
241-function MyAddon.AddGGFContext(data)
242->	AddCustomMenuItem("Save to MyAddon", function() MyAddon.SavePlayer(data.displayName) end)
243-end

245-function MyAddon.SavePlayer(displayName)
246	MyAddon.savedVariables.savedPlayer = displayName
247	df("|c6666FF[MyAddon]|r Saving: " .. tostring(displayName))-- WORKING FINE
248->	MyAddon_SETTINGS_SAVEDPLAYER_TEXT.data.text = "Saved Player: " .. tostring(displayName)-- ERRORS APPEAR TO BE HERE AND BELOW REPORTING NIL VALUE FOR IM ASSUMING "displayName"
249-	MyAddon_SETTINGS_SAVEDPLAYER_TEXT:UpdateValue()
250-end
ERRORS:
Code:
user:/AddOns/MyAddon/MyAddon.lua:248: attempt to index a nil value
stack traceback:
user:/AddOns/MyAddon/MyAddon.lua:248: in function 'MyAddon.SavePlayer'
user:/AddOns/MyAddon/MyAddon.lua:242: in function 'OnSelect'
/EsoUI/Libraries/ZO_ContextMenus/ZO_ContextMenus.lua:476: in function 'ZO_Menu_ClickItem'
user:/AddOns/LibCustomMenu/LibCustomMenu.lua:604: in function 'MouseUp'

Last edited by sinnereso : 03/26/23 at 05:18 PM.
  Reply With Quote