Thread Tools Display Modes
09/22/17, 03:31 AM   #1
vvarderen
 
vvarderen's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 20
noob question by one noob

hi all,

I have a question that may seem stupid in the eyes of many, but I am not a developer (I am nevertheless trying to improve), and I would like to know what it should be and should not do or put in files (basically, knowing a potential good practice or something like that):

- controls.lua
- function.lua

Sorry for my english and thank you for your answers.
  Reply With Quote
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,912
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
09/25/17, 03:41 AM   #3
vvarderen
 
vvarderen's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 20
My question was rather to understand the essence of the contents of the files "controls" and "function" that are found in many addon, and their real differences, and why to separate into two files their contents.
  Reply With Quote
09/25/17, 04:00 AM   #4
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
it's dev preference, nothing, more.
  Reply With Quote
09/26/17, 08:37 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
As written above:
Some developers split it up (better readability, whatever reason they got) and some don't.
  Reply With Quote

ESOUI » Developer Discussions » Tutorials & Other Helpful Info » noob question by one noob

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