Thread Tools Display Modes
05-15-21, 06:21 PM   #1
Darkonode
A Murloc Raider
 
Darkonode's Avatar
Join Date: May 2021
Posts: 8
New author requiring aid for their first addon

I've been learning addon coding for a few days now. Especially i've been looking through this video series on youtube.
https://www.youtube.com/watch?v=nfaE...ZBM2t1exFmoA2G
I'm familiar with Python but I haven't coded with lua before.

I've followed the videos till episode 9 and created a main window and some frames and buttons within it. Now I want to have multiple tabs that have the said frames and buttons in them. The addon stopped loading after I entered the code for the tab creation and I suspect I have errors in how I create the tabs. I can't blindly follow the tutorial video either, since in the tutorial series episode 9 Mayron creates tabs from ScrollFrames, which I don't need. I just want a plain old static frame with stuff on it so I've just used a Frame with no visible elements in it to anchor the other elements to for each tab.

I've debugged before by comparing Mayron's code from the tutorial series' github to my own, but this time I can't seem to figure out what's up.
Attached Files
File Type: lua config.lua (4.9 KB, 110 views)
File Type: lua init.lua (2.6 KB, 105 views)
  Reply With Quote
05-15-21, 06:52 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
The video is from 2014 which means alot of the code is way out of date and is likely the cause of the errors. Nearly every addon breaks when an expansion comes out every 2 or 3 years or a new feature is introduced during an expansion.

A quick look at the code you attached and init.lua looks like it may be fine. config.lua could have template frames that no longer exist. Have a look through Blizzards files to see what frames there are. You will find their frames defined for the most part if not all of them in the relative XML file.
https://www.townlong-yak.com/framexml/live

Shared Panel Template definitions - use this to find the names of the frames and their components
https://www.townlong-yak.com/framexm...lTemplates.xml


I would suggest looking at the tutorial section and browsing this site to see what is currently available.

https://wowpedia.fandom.com/wiki/Wow..._customization


Once you have dabbled a bit and got the basics down, try looking for an addon that is simple and similar to what you want to expand on as you learn.
Take a look at their code and see if you can identify portions of it and what they do.

Anything confusing you .. feel free to ask. I am sure between us that we have played with enough of the wow api to be able to offer some advice.
__________________

Last edited by Xrystal : 05-15-21 at 06:58 PM.
  Reply With Quote
05-15-21, 08:11 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,857
Along with Xrystal's advice and to help with debugging, install
BugGrabber
and
BugSack

Without looking at anything it points out that your missing a "then" in config.lua at:

if (SelectedTab:GetID() ~= self:GetID())

and at:
Code:
local function SetTabs (frame numTabs, ...)
you're missing a , (comma) after frame

there may be others.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-15-21 at 08:49 PM.
  Reply With Quote
05-16-21, 06:55 AM   #4
Darkonode
A Murloc Raider
 
Darkonode's Avatar
Join Date: May 2021
Posts: 8
Thank you so much thus far for helping me. You've helped me quite a bit!

Originally Posted by Fizzlemizz View Post
...
Without looking at anything it points out that your missing a "then" in config.lua at:

if (SelectedTab:GetID() ~= self:GetID())

and at:
Code:
local function SetTabs (frame numTabs, ...)
you're missing a , (comma) after frame

there may be others.
Oh.. my.. god.. it was literally this + another missing parenthesis and some parenting issues that i was able to spot after I slept overnight. I will deffo have a look at the debugging tools too!

Originally Posted by Xrystal View Post
The video is from 2014 which means alot of the code is way out of date and is likely the cause of the errors. Nearly every addon breaks when an expansion comes out every 2 or 3 years or a new feature is introduced during an expansion.

A quick look at the code you attached and init.lua looks like it may be fine. config.lua could have template frames that no longer exist. Have a look through Blizzards files to see what frames there are. You will find their frames defined for the most part if not all of them in the relative XML file.
https://www.townlong-yak.com/framexml/live

Shared Panel Template definitions - use this to find the names of the frames and their components
https://www.townlong-yak.com/framexm...lTemplates.xml


I would suggest looking at the tutorial section and browsing this site to see what is currently available.

https://wowpedia.fandom.com/wiki/Wow..._customization
...
I exported Blizzard code from the game client and have been using that as a reference for templates. I already had to make a change to some templates that mayron was using as they weren't present in the WoW classic client. Also I've noticed that not many addons use the default blizzard templates, at least not the ones that I use a lot and it has sometimes been tricky to find example usage of certain frames this way.

For my code right now, I managed to get it to show all the elements that I wanted. Now my problem is just in creating the tabs and attaching the content frame to the tab, which based on Mayron's code should be very simple but again I'm not sure what I'm doing wrong. I reckon the fault is in this function as the tabs won't even show on the main frame(?)
Code:
local function SetTabs (frame, numTabs, ...)
	frame.numTabs = numTabs
	local tabs = {}
	local frameName = frame:GetName()
	
	for i = 1, numTabs do
		local tab = CreateFrame("Button", frameName.."Tab"..i, frame, "CharacterFrameTabButtonTemplate")
		tab:SetID(i)
		tab:SetText(select(i, ...))
		tab.SetScript("OnClick", Tab_OnClick)
		
		tab.content = CreateFrame("Frame", nil, ConfigWin)
		tab.content:SetSize(600, 300)
		tab.content:SetPoint("CENTER", tab, "CENTER")
		tab.content:Hide()
		
		if (i == 1) then
			tab:SetPoint("TOPLEFT", ConfigWin, "BOTTOMLEFT", 5, 7)
		else
			tab:SetPoint("TOPLEFT", _G[frameName.."Tab"..(i-1)], "TOPRIGHT", -14, 0)
		end
		
	end
	
	Tab_OnClick(_G[frameName.."Tab1"])
	
	return unpack(tabs)
end
Updated config.lua attached.
Attached Files
File Type: lua config.lua (4.8 KB, 96 views)
  Reply With Quote
05-16-21, 07:00 AM   #5
Darkonode
A Murloc Raider
 
Darkonode's Avatar
Join Date: May 2021
Posts: 8
OMG and I LITERALLY noticed it straight after i posted T.T. Well, for your entertainment it was this line in the function I posted
Code:
tab.SetScript("OnClick", Tab_OnClick)
which should be
Code:
tab:SetScript("OnClick", Tab_OnClick)
Now it works! Almost... I'm still missing all the contents I wish to be shown on the tabs.

EDIT: I figured it out! I forgot a table insert from the SetTabs function, which made it return nil for the PopulateTabs function causing a lua error.

Last edited by Darkonode : 05-16-21 at 09:55 AM.
  Reply With Quote
05-17-21, 04:32 AM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
woohoo .. let the addon creation times begin Congratulations on your first addon
__________________
  Reply With Quote
05-18-21, 03:14 PM   #7
Darkonode
A Murloc Raider
 
Darkonode's Avatar
Join Date: May 2021
Posts: 8
Getting a weird lua error i can't understand

Progress on my addon has been steady, but now I hit an error that i can't figure out. I am setting up buttons with OptionsListButtonTemplate and I am getting a weird lua error when I open the addon window.

Error is as follows:
Code:
Message: Interface\FrameXML\OptionsFrameTemplates.lua:131: attempt to concatenate a nil value
Time: Wed May 19 00:03:54 2021
Count: 1
Stack: Interface\FrameXML\OptionsFrameTemplates.lua:131: attempt to concatenate a nil value
Interface\FrameXML\OptionsFrameTemplates.lua:131: in function `OptionsListButton_OnLoad'
[string "*:OnLoad"]:1: in function <[string "*:OnLoad"]:1>
[C]: in function `CreateFrame'
Interface\AddOns\WishlistLC\config.lua:161: in function <Interface\AddOns\WishlistLC\config.lua:108>
Interface\AddOns\WishlistLC\config.lua:184: in function `CreateMenu'
Interface\AddOns\WishlistLC\config.lua:27: in function `?'
Interface\AddOns\WishlistLC\init.lua:46: in function `?'
Interface\FrameXML\ChatFrame.lua:4699: in function `ChatEdit_ParseText'
Interface\FrameXML\ChatFrame.lua:4362: in function `ChatEdit_SendText'
Interface\FrameXML\ChatFrame.lua:4398: in function `ChatEdit_OnEnterPressed'
[string "*:OnEnterPressed"]:1: in function <[string "*:OnEnterPressed"]:1>

Locals: self = <unnamed> {
 0 = <userdata>
 toggle = WLC_ConfigWinToggle {
 }
}
toggleFunc = nil
(*temporary) = <table> {
 UpdateOnBarHighlightMarksBySpell = <function> defined @Interface\FrameXML\ActionButton.lua:70
 ERR_OUT_OF_CHI = "Not enough chi"
 DH_HAVOC_CORE_ABILITY_2 = "Strong melee attack that consumes Fury. If it critical strikes, some Fury is refunded."
 MerchantItem9ItemButtonStock = MerchantItem9ItemButtonStock {
 }
 GetTrainerServiceTypeFilter = <function> defined =[C]:-1
 UNIT_NAMES_COMBATLOG_TOOLTIP = "Color unit names."
 SetTrainerServiceTypeFilter = <function> defined =[C]:-1
 LE_GAME_ERR_CHAT_RAID_RESTRICTED_TRIAL = 742
 SPELL_FAILED_CUSTOM_ERROR_71 = "This partygoer wants to dance with you."
 LE_GAME_ERR_PET_SPELL_TARGETS_DEAD = 399
 ERROR_CLUB_TICKET_COUNT_AT_MAX_COMMUNITY = "Can't create any more invite links for this group."
 RecruitAFriendFrame = RecruitAFriendFrame {
 }
 CompactUnitFrameProfilesGeneralOptionsFrameHealthTextDropdownButtonNormalTexture = CompactUnitFrameProfilesGeneralOptionsFrameHealthTextDropdownButtonNormalTexture {
 }
 ERR_TRADE_EQUIPPED_BAG = "You can't trade equipped bags."
 PVP_RANK_6_1 = "Corporal"
 MultiBarLeftButton7 = MultiBarLeftButton7 {
 }
 InterfaceOptionsNamesPanelUnitNameplatesShowAll = InterfaceOptionsNamesPanelUnitNameplatesShowAll {
 }
 VideoOptionsFrameDefaults = VideoOptionsFrameDefaults {
 }
 MerchantItem2AltCurrencyFrameItem1Text = MerchantItem2AltCurrencyFrameItem1Text {
 }
 OPTION_TOOLTIP_ACTION_BUTTON_USE_KEY_DOWN = "Action button keybinds will respond on key down, rather than on key up."
 BINDING_NAME_NAMEPLATES = "Show Enemy Name Plates"
 INSTANCE_UNAVAILABLE_OTHER_TEMPORARILY_DISABLED = "%s cannot enter. This instance is temporarily disabled."
 MultiBarBottomRightButton8Shine5 = MultiBarBottomRightButton8Shine5 {
 }
 IsReferAFriendLinked = <function> defined =[C]:-1
 MAIL_LETTER_TOOLTIP = "Click to make a permanent
copy of this letter."
 UnitFrameManaBar_UnregisterDefaultEvents = <function> defined @Interface\FrameXML\UnitFrame.lua:602
 DUNGEON_FLOOR_UPPERBLACKROCKSPIRE3 = "Hall of Blackhand"
 CHAT_CONFIG_OTHER_COMBAT = <table> {
 }
 FCFDockOverflowButton_OnClick = <function> defined @Interface\FrameXML\FloatingChatFrame.lua:2373
 BOOST2_WARRIOR_COLOSSUSSMASH = "Use Colossus Smash.

Colossus Smash increases your damage."
 BN_UNABLE_TO_RESOLVE_NAME = "Unable to whisper '%s'. Blizzard services may be unavailable."
 AutoCompleteEditBox_OnKeyDown = <function> defined @Interface\FrameXML\AutoComplete.lua:371
 CompactRaidFrameManagerDisplayFrameHiddenModeToggleTopRight = CompactRaidFrameManagerDisplayFrameHiddenModeToggleTopRight {
 }
 LE_GAME_ERR_ONLY_ONE_QUIVER = 32
 SpellButton6Cooldown = SpellButton6Cooldown {
 }
 LOSS_OF_CONTROL_DISPLAY_FEAR = "Feared"
 Graphics_QualityText = Graphics_QualityText {
 }
 ROGUE_COMBAT_CORE_ABILITY_4 = "Melee ability with an increased range that consumes Combo Points."
 StanceButton4FlyoutArrow = StanceButton4FlyoutArrow {
 }
 MultiBarRightButton7Shine9 = Multi
I get 3 of these and I have no idea what's causing them. Trying to look through them and seeing stuff like ability descriptions makes me scratch my head even more.
Attached Files
File Type: lua config.lua (5.7 KB, 95 views)
  Reply With Quote
05-18-21, 03:34 PM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,857
You probably need to create that frame with a name:

Code:
tab.searchRow = CreateFrame("Button", "$parentSearchRow", tab, "OptionsListButtonTemplate")
and maybe others.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-18-21, 04:27 PM   #9
Darkonode
A Murloc Raider
 
Darkonode's Avatar
Join Date: May 2021
Posts: 8
Originally Posted by Fizzlemizz View Post
You probably need to create that frame with a name:

Code:
tab.searchRow = CreateFrame("Button", "$parentSearchRow", tab, "OptionsListButtonTemplate")
and maybe others.
That was it. Thank you so much for the fast reply!
Now looking at the error again, I also notice the:
Code:
[string "*:OnLoad"]
which indicates that it needs a global name.
  Reply With Quote
05-20-21, 06:13 AM   #10
Darkonode
A Murloc Raider
 
Darkonode's Avatar
Join Date: May 2021
Posts: 8
ScrollFrameChild seems to be properly applied to ScrollFrame

So for some reason my ItemScrollFrame doesn't clip my scroll child contents. It's supposed to be done by a single line of code

Code:
tab.ItemScrollFrame:SetScrollChild(tab.ItemScrollFrameChild)
but it doesn't. The green area in the screenshot is my scroll frame.
https://imgur.com/a/cyI4DfQ

I've created my buttons so all of them are parented to the scroll frame

Code:
	local ButtonIndex = {}
	local index = 1
	local first_elem = true
	for key, item in next, namespace.searchResult do
		local buttonName = key .. "Button"
		if first_elem then
			tab.buttonName = CreateFrame("Button", buttonName, tab.ItemScrollFrame, "OptionsListButtonTemplate")
			tab.buttonName:SetPoint("TOPLEFT", tab.ItemScrollFrameChild, "TOPLEFT", 4, -4)
			tab.buttonName:SetSize(192, 10)
			tab.buttonName:SetHighlightTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2")
			tab.buttonName:SetText(item.name)
			if item.slot then
				tab.buttonName.tooltipText = item.itemType .. ", " .. item.slot
			else
				tab.buttonName.tooltipText = item.itemType
			end
			tab.buttonName:SetScript("OnEnter", OnEnter)
			tab.buttonName:SetScript("OnLeave", OnLeave)
			tab.buttonName:SetScript("OnClick", OnClickItemFrameButton)
			table.insert(ButtonIndex, buttonName)
			index = index + 1
			first_elem = false
		else
			tab.buttonName = CreateFrame("Button", buttonName, tab.ItemScrollFrame, "OptionsListButtonTemplate")
			tab.buttonName:SetPoint("TOPLEFT", ButtonIndex[index - 1], "TOPLEFT", 0, -11)
			tab.buttonName:SetSize(192, 10)
			tab.buttonName:SetHighlightTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2")
			tab.buttonName:SetText(item.name)
			if item.slot then
				tab.buttonName.tooltipText = item.itemType .. ", " .. item.slot
			else
				tab.buttonName.tooltipText = item.itemType
			end
			tab.buttonName:SetScript("OnEnter", OnEnter)
			tab.buttonName:SetScript("OnLeave", OnLeave)
			tab.buttonName:SetScript("OnClick", OnClickItemFrameButton)
			table.insert(ButtonIndex, buttonName)
			index = index + 1
		end
	end
	tab.ItemScrollFrameChild:SetSize(190, index * 11)
Attached Files
File Type: lua config.lua (9.1 KB, 92 views)

Last edited by Darkonode : 05-20-21 at 07:04 AM.
  Reply With Quote
05-20-21, 07:26 AM   #11
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 223
SetClipsChildren

If memory serves you may need to include SetClipsChildren(bool).

Lua Code:
  1. tab.ItemScrollFrame:SetClipsChildren(true)
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
  Reply With Quote
05-20-21, 08:44 AM   #12
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
In addition to what jeruku said, you aren't parenting the entries to the scroll child to begin with. You are also repeating a lot of code when it could be avoided:
Lua Code:
  1. tab.ItemScrollFrame:SetClipsChildren(true)
  2.  
  3. local numButtons, lastButton = 0
  4. for key, item in pairs(namespace.searchResult) do
  5.     local buttonName = key .. "Button"
  6.     local button = CreateFrame("Button", buttonName, tab.ItemScrollFrameChild, "OptionsListButtonTemplate")
  7.     button:SetSize(192, 10)
  8.     button:SetHighlightTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2")
  9.     button:SetText(item.name)
  10.     if item.slot then
  11.         button.tooltipText = item.itemType .. ", " .. item.slot
  12.     else
  13.         button.tooltipText = item.itemType
  14.     end
  15.     button:SetScript("OnEnter", OnEnter)
  16.     button:SetScript("OnLeave", OnLeave)
  17.     button:SetScript("OnClick", OnClickItemFrameButton)
  18.     if lastButton then
  19.         button:SetPoint("TOPLEFT", lastButton, "BOTTOMLEFT", 0, -1)
  20.     else
  21.         button:SetPoint("TOPLEFT", 4, -4)
  22.     end
  23.     numButtons, lastButton = numButtons + 1, button
  24.     tab[buttonName] = button
  25. end
  26.  
  27. if lastButton then
  28.     local width, height = lastButton:GetSize()
  29.     tab.ItemScrollFrameChild:SetSize(width, numButtons * (height + 1) - 1)
  30. end
I'm unsure what you are trying to accomplish with the "tab.buttonName" stuff unless you meant "tab[buttonName]" so that's what I changed it to, remove it if you aren't actually using it elsewhere.
  Reply With Quote
05-20-21, 01:10 PM   #13
Darkonode
A Murloc Raider
 
Darkonode's Avatar
Join Date: May 2021
Posts: 8
Originally Posted by Vrul View Post
In addition to what jeruku said, you aren't parenting the entries to the scroll child to begin with. You are also repeating a lot of code when it could be avoided:
Lua Code:
  1. tab.ItemScrollFrame:SetClipsChildren(true)
  2.  
  3. local numButtons, lastButton = 0
  4. for key, item in pairs(namespace.searchResult) do
  5.     local buttonName = key .. "Button"
  6.     local button = CreateFrame("Button", buttonName, tab.ItemScrollFrameChild, "OptionsListButtonTemplate")
  7.     button:SetSize(192, 10)
  8.     button:SetHighlightTexture("Interface\\BUTTONS\\UI-Listbox-Highlight2")
  9.     button:SetText(item.name)
  10.     if item.slot then
  11.         button.tooltipText = item.itemType .. ", " .. item.slot
  12.     else
  13.         button.tooltipText = item.itemType
  14.     end
  15.     button:SetScript("OnEnter", OnEnter)
  16.     button:SetScript("OnLeave", OnLeave)
  17.     button:SetScript("OnClick", OnClickItemFrameButton)
  18.     if lastButton then
  19.         button:SetPoint("TOPLEFT", lastButton, "BOTTOMLEFT", 0, -1)
  20.     else
  21.         button:SetPoint("TOPLEFT", 4, -4)
  22.     end
  23.     numButtons, lastButton = numButtons + 1, button
  24.     tab[buttonName] = button
  25. end
  26.  
  27. if lastButton then
  28.     local width, height = lastButton:GetSize()
  29.     tab.ItemScrollFrameChild:SetSize(width, numButtons * (height + 1) - 1)
  30. end
I'm unsure what you are trying to accomplish with the "tab.buttonName" stuff unless you meant "tab[buttonName]" so that's what I changed it to, remove it if you aren't actually using it elsewhere.
the naming was probably just something that carried over from previous code. I needed it to be able to modify the buttons later once i enable search functionality but since im using a table for them anyway and a global name i dnt really need it anymore.

rn im genrally repeating a lot of code cos this is my first lua project and i just write the down the solution that comes to mind and i can implement LOL. how you handled setting size for the later buttons didnt even cross my mind. i will clean it up once i get a bit further.
  Reply With Quote
05-30-21, 06:52 AM   #14
Darkonode
A Murloc Raider
 
Darkonode's Avatar
Join Date: May 2021
Posts: 8
Can't get SavedVariables to work

I'm habing trouble getting saved variables to work for saving wishlists in my addon. I found a little tutorial on WoWwiki https://wowwiki-archive.fandom.com/w..._game_sessions that I've been consulting thus far and I'm obviously hitting one of the pitfalls mentioned in the article where I'm loading the variables wrong and overwriting something. Sadly the article doesn't give me any further hints and I've tried to move the variable load around without much results.

So as a small preamble here's some logic what the addon does:

Create the main window --> Create all the raid tabs --> Populate the raid tabs with all the elements as they are created by the previous function. By default, open the Kara tab and do a full (kara) item database search (the search is done before tabs are created). By default the wishlist is empty.

I would like the wishlist to default to either empty, or to load the last known one. After a raid tab is created and it's elements are created (this is where im trying to load the wishlist as well), the default kara tab gets opened, which is where I get a nil error indicating to me that the loading of the wishlist overwrote something.

This is the error im getting. Googling around this apparently indicates that whatever SetPoint is being called for doesn't exist.
Code:
Message: Interface\AddOns\WishlistLC\config.lua:89: attempt to call method 'SetPoint' (a nil value)
Time: Sun May 30 15:38:46 2021
Count: 1
Stack: Interface\AddOns\WishlistLC\config.lua:89: attempt to call method 'SetPoint' (a nil value)
[string "@Interface\AddOns\WishlistLC\config.lua"]:89: in function <Interface\AddOns\WishlistLC\config.lua:84>
[string "@Interface\AddOns\WishlistLC\config.lua"]:204: in function <Interface\AddOns\WishlistLC\config.lua:191>
[string "@Interface\AddOns\WishlistLC\config.lua"]:360: in function <Interface\AddOns\WishlistLC\config.lua:333>
[string "@Interface\AddOns\WishlistLC\config.lua"]:377: in function `CreateMenu'
[string "@Interface\AddOns\WishlistLC\config.lua"]:34: in function `?'
[string "@Interface\AddOns\WishlistLC\init.lua"]:46: in function `?'
[string "@Interface\FrameXML\ChatFrame.lua"]:4825: in function `ChatEdit_ParseText'
[string "@Interface\FrameXML\ChatFrame.lua"]:4488: in function `ChatEdit_SendText'
[string "@Interface\FrameXML\ChatFrame.lua"]:4524: in function `ChatEdit_OnEnterPressed'
[string "*:OnEnterPressed"]:1: in function <[string "*:OnEnterPressed"]:1>

Locals: raid = "Karazhan"
index = 1
first_elem = true
(for generator) = <function> defined =[C]:-1
(for state) = <table> {
 1 = <table> {
 }
 2 = <table> {
 }
 3 = <table> {
 }
 4 = <table> {
 }
 5 = <table> {
 }
 6 = <table> {
 }
 7 = <table> {
 }
 8 = <table> {
 }
 9 = <table> {
 }
 10 = <table> {
 }
 11 = <table> {
 }
 12 = <table> {
 }
 13 = <table> {
 }
 14 = <table> {
 }
}
(for control) = 1
key = 1
itemButton = <table> {
 toggle = <table> {
 }
 text = <table> {
 }
 highlight = <table> {
 }
 tooltipText = "Leather, Legs"
}
(*temporary) = nil
(*temporary) = <table> {
 toggle = <table> {
 }
 text = <table> {
 }
 highlight = <table> {
 }
 tooltipText = "Leather, Legs"
}
(*temporary) = "TOPLEFT"
(*temporary) = KarazhanWishScrollChild {
 0 = <userdata>
}
(*temporary) = "TOPLEFT"
(*temporary) = 4
(*temporary) = 0
(*temporary) = "attempt to call method 'SetPoint' (a nil value)"
namespace = <table> {
 Raids = <table> {
 }
 currentRaid = 1
 commands = <table> {
 }
 Print = <function> defined @Interface\AddOns\WishlistLC\init.lua:60
 init = <function> defined @Interface\AddOns\WishlistLC\init.lua:66
 CommitMemory = <function> defined @Interface\AddOns\WishlistLC\init.lua:96
 Config = <table> {
 }
 ItemFrameElements = <table> {
 }
 filter = "all"
 Kara = <table> {
 }
 searchResults = <table> {
 }
 Ketho = <table> {
 }
 wishlists = <table> {
 }
}
which goes back to this function and the bolded line
Code:
local function UpdateWishlistFrame(raid)
	local index = 1
	local first_elem = true
	for key, itemButton in next, namespace.wishlists[raid] do
		if first_elem then
			itemButton:SetPoint("TOPLEFT", _G[raid .. "WishScrollChild"], "TOPLEFT", 4, 0)
			first_elem = false
		else
			itemButton:SetPoint("TOPLEFT", namespace.wishlists[raid][index - 1], "TOPLEFT", 0, -11)
		end
		itemButton:Show()
		index = index + 1
	end
	_G[raid .. "WishScrollChild"]:SetSize(195, index * 11)
	
end
Right now im trying to load the wishlist before any tabs are even created. My table for wishlists is like this
Code:
namespace.wishlists = {["Karazhan"] = {},["Gruul"] = {}, ["Magth"] = {},}
the saved variables (per character obviously) version is almost the same
Code:
savedWishlists = {["Karazhan"] = {},["Gruul"] = {}, ["Magth"] = {},}
and when I load them I do it like this
Code:
]namespace.wishlists = savedWishlists
I've also registered an event in my init.lua for saving the wishlists
Code:
function namespace:CommitMemory(event, name)
	if (name ~= "WishlistLC") then return end
	_G[savedWishlists] = namespace.wishlists
end

local save = CreateFrame("Frame")
save:RegisterEvent("PLAYER_LOGOUT")
save:SetScript("OnEvent", namespace.CommitMemory)
Any hints would be greatly appreciated

EDIT: Sorry for the kinda messu config file. Havent cleaned it up.
Attached Files
File Type: lua config.lua (12.8 KB, 101 views)
File Type: lua init.lua (2.9 KB, 86 views)
File Type: lua kara.lua (23.5 KB, 110 views)

Last edited by Darkonode : 05-30-21 at 06:55 AM.
  Reply With Quote
05-30-21, 09:07 AM   #15
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,857
The error indicates that you've added something to the namespace.wishlists[raid] table that is not a frame, texture, fontstring etc. A quick check before the SetPoint would be to see what you're trying to action by inserting

print(key, itemButton, itemButton.SetPoint)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
05-30-21, 09:25 AM   #16
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,877
Also you might want to use this site as it is more up to date than that one you have been using.

https://wowpedia.fandom.com/wiki/Wow..._customization
__________________
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » New author requiring aid for their first addon

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off