New author requiring aid for their first addon
2 Attachment(s)
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. |
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. |
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, ...) there may be others. |
1 Attachment(s)
Thank you so much thus far for helping me. You've helped me quite a bit!
Quote:
Quote:
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, ...) |
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) Code:
tab:SetScript("OnClick", Tab_OnClick) 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. |
woohoo .. let the addon creation times begin :) Congratulations on your first addon
|
Getting a weird lua error i can't understand
1 Attachment(s)
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 |
You probably need to create that frame with a name:
Code:
tab.searchRow = CreateFrame("Button", "$parentSearchRow", tab, "OptionsListButtonTemplate") |
Quote:
Now looking at the error again, I also notice the: Code:
[string "*:OnLoad"] |
ScrollFrameChild seems to be properly applied to ScrollFrame
1 Attachment(s)
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) https://imgur.com/a/cyI4DfQ I've created my buttons so all of them are parented to the scroll frame Code:
local ButtonIndex = {} |
SetClipsChildren
If memory serves you may need to include SetClipsChildren(bool).
Lua Code:
|
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:
|
Quote:
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. |
Can't get SavedVariables to work
3 Attachment(s)
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) Code:
local function UpdateWishlistFrame(raid) Code:
namespace.wishlists = {["Karazhan"] = {},["Gruul"] = {}, ["Magth"] = {},} Code:
savedWishlists = {["Karazhan"] = {},["Gruul"] = {}, ["Magth"] = {},} Code:
]namespace.wishlists = savedWishlists Code:
function namespace:CommitMemory(event, name) EDIT: Sorry for the kinda messu config file. Havent cleaned it up. |
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) |
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 |
All times are GMT -6. The time now is 01:43 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI