First time addon author, not sure why my code isn't working
hello, I am a senior in high school doing an independent study program with my CS teacher, which basically lets us choose a project that will both look good on a future resume and further our knowledge in computer science. I chose to write an addon for wow, which would basically be a very simple DK interface to replace the blizzard one (the concept isn't to make something revolutionary or completely new, it's just to make something that you can say you did yourself without just copying someone elses' code). It's supposed to track diseases, runic power, and the cooldown on the 6 runes.
I did a fair amount of it on my own, but since this is the first project I'm doing in Lua my teacher had to help in a few places (the OOP-simulating was her idea), but after that I should be able to do everything myself. I'm getting an error: line 208 attempt to call field 'constructor' (a nil value), not really sure why this is happening. does anyone know? code is here https://pastebin.com/MrZAaJNU apologies if it's not the best, I only started Lua in September and I've only been coding for a few years :P |
You never defined constructor as file scope, so it doesn't exist on line 208. I think you meant to type either self.constructor or framesConstructor. I didn't really pay enough attention to make sure which one to use, sorry.
Also, table.getn was depreciated a few years ago. use # instead, like Code:
local table_length = #MyTable |
Code:
framesConstructor:create Code:
self.constructor = constructor Code:
framesConstructor.constructor = constructor Code:
function framesConstructor:create(name, width, height, constructor, updater)--method for frame creation - simulates OOP |
Quote:
The intent by using allFrames instead of framesConstructer was to simulate object oriented programming. I wanted to do this with Code:
allFrames[#allFrames + 1] = framesConstructor:create("runicpower", 120, 16, setupRpower, updateRpower) |
Lua Code:
The first 3 tinserts replicate what you are doing and in the print, they all end up containing the information of the last call to create() because "return self" means return framesConstructor (always returning the same table, not a new instance). The last 3 create/return a new table each call containing the passed information. If you wanted an inherited "instance" of framesConstructor for each entry: Lua Code:
|
Fizzle, thanks! I guess I missed that. There are no more errors, and it prints the 3 setup lines (runic power setup/runes setup/diseases setup) but now the problem is that there's nothing actually showing on the screen.. I thought "allFrames[i].frame:Show()" would show all 3 of them.
|
By default, frames are shown.
Is your latest code on PasteBin? |
The only time I haven't had my frames showing is when I have either forgotten to specify a size when it needs it or anchors or told it to hide but forgot to change it or that it was supposed to be like that.
If nothing else surfaces as a reason you might want to make sure that that isn't your problem. |
In framesConstructor:create
.frame has no SetPoint() It appears everything else is anchored to it |
Quote:
Quote:
Thanks a ton guys! There are still a few things missing that need to be worked out but I think I'll be able to manage them myself! Thank you again:) |
All times are GMT -6. The time now is 08:47 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI