Not used to object based yet....
Can't test these things yet, but wanna see if I'm doing things correctly. Using DuctTape to learn (most code obviously cut):
dt.lua Moreso, I'm worried about saved var declaration in the .toc: Code:
SavedVariablesPerCharacter: DT.on |
What's the question?
And the question is?
|
The basic principle is correct - moving all functions and important variables into your addon table. But there are some mistakes which prevent your code from working:
Code:
lines 4 and 17 Code:
lines 19 and 33 Code:
line 37 Code:
lines 40 and 41 Some tips: 1) Do not try to store all variables in your tables, but only the ones which need to be accessed from other places (or different files). For example, dt.list could as well be just a simple 'local list'. 2) You could eliminate the whole dt.f-variable and the confusion concerning the event-function by just declaring your frame as the addons namespace, e.g. by writing 'DT = DT or CreateFrame("Frame")' on top of the file. Just remember: frames are tables, too :) Last, but not least: Do not 'enforce' object-oriented programming on all things you come across. Just do it where it makes sense, e.g. defining a global namespace for your important addon functions or passing 'self'. Local variables/functions still have their use and are not excluded by OOP. Just try to find a good balance ;) Good luck on your further scripting! OOP makes things a lot more structured and is imho more fun to write. |
Code:
lines 4 and 17 Code:
lines 19 and 33 Code:
line 37 EDIT: Wait, I see now. I did this before and confused me for days. I see what you're saying now. Code:
lines 40 and 41 Quote:
Quote:
Quote:
Quote:
Thanks for the advice so far, much appreciated. |
All times are GMT -6. The time now is 04:51 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI