View Single Post
09/22/17, 06:57 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
and I would like to know what it should be and should not do or put in files
Hi,

I'm not sure if I understand you. Do you want to know what a "best practice" for writing an addon should be?
If you should split your addon into several lua files, one for controls, the other for functions, etc.?

In my opinion it depends on the size of your project/addon. I'd start with a single file and local variables like
Lua Code:
  1. local myAddon = {}
  2. myAddon.name = "My Addon's name"
  3. myAddon.version = 0.1
  4.  
  5. function myAddon.myfunc(param1, param2)
  6. ...
  7. end

in there, and then advance it to using multiple files and global variables that can be used in several files
Lua Code:
  1. --File controls.lua
  2. myGlobalAddon = {}
  3.  
  4. myGlobalAddon.name = "My Addon's name"
  5. myGlobalAddon.version = 0.1
  6.  
  7. myGlobalAddon.baseControl = WINDOW_MANAGER:CreateControl(......)
  8.  
  9. --File functions.lua
  10. if myGlobalAddon == nil then myGlobalAddon = {} end
  11.  
  12. function myGlobalAddon.funcName(param1, param2)
  13. ...
  14. end

Check these links for eso addon development:

http://wiki.esoui.com/Main_Page -> At the right side below "How-To Guides"

http://wiki.esoui.com/Getting_Started
http://wiki.esoui.com/Writing_your_first_addon
  Reply With Quote