ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Splitting up Add-on into Multiple Files (https://www.esoui.com/forums/showthread.php?t=10870)

static_recharge 03/13/24 06:20 AM

Splitting up Add-on into Multiple Files
 
Hello I was hoping someone could explain to me good practices (and how they work) for splitting up a large add-on into multiple files. For example having one file for the settings menu information (settingsmenu.lua for example). I'm trying to mimic what I see in other add-ons by using _G[] and whatnot but I'm just not understanding the full picture and how methods play a role into this. I've tried the following code:

Start of StaticsRecruiter.lua
Code:

local SR = _G['StaticsRecruiter']
SR.addonName = "Static's Recruiter"

Start of SettingsMenu.lua
Code:

local SR = _G['StaticsRecruiter']
function SR:Create settings menu()
...
end

When my code runs it says it's attempting to index a nil value at the
Quote:

function SR:Create settings menu()
line.

Any help or pointing in the right direction is appreciated. I tried searching the forums but I couldn't find anything on the subject. I might have been using the wrong terms. Thanks in advance.

sirinsidiator 03/13/24 08:10 AM

Check the wiki. There are some tutorials. This one for example is exactly about what you are asking.

Baertram 03/13/24 11:21 AM

Also remember that the : notation for function calls shoud be used for created objects of classes (created via ZO_Object:SubClass() e.g. where you can use self to reference the created object), and not simple tables {}.

So if SR = {} only, better do not use function SR:FunctionName but SR.FunctionName and calls as well via . and not : notation.
Easier to read and to understand.

In the end it works with : too, right. But the usage of "self" for simple tables is not intended afaik

static_recharge 03/13/24 01:23 PM

Thank you for the quick replies everyone. It has been a while since I looked at that tutorial and had forgotten that it showed what I needed. I'll read that over again. Cheers!


All times are GMT -6. The time now is 10:14 PM.

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