ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Tutorials & Other Helpful Info (https://www.esoui.com/forums/forumdisplay.php?f=172)
-   -   noob question by one noob (https://www.esoui.com/forums/showthread.php?t=7375)

vvarderen 09/22/17 03:31 AM

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.

Baertram 09/22/17 06:57 AM

Quote:

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

vvarderen 09/25/17 03:41 AM

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.

Ayantir 09/25/17 04:00 AM

it's dev preference, nothing, more.

Baertram 09/26/17 08:37 AM

As written above:
Some developers split it up (better readability, whatever reason they got) and some don't.


All times are GMT -6. The time now is 11:32 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI