WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Ace3 Module with sub modules? (https://www.wowinterface.com/forums/showthread.php?t=57308)

Lybrial 07-24-19 10:08 AM

Ace3 Module with sub modules?
 
Hi,

im using Ace3 since its making a lot of work much easier. Today I was wondering
if it is possible to create Ace3 modules with submodules.

Usually you create modules for addons like this:

Lua Code:
  1. AddOn = ACE3:NewAddon("AddOn");
  2. Module = AddOn:NewModule("Module");

What I would like to do is something like this:

Lua Code:
  1. AddOn = ACE3:NewAddon("AddOn");
  2. Module = AddOn:NewModule("Module");
  3. SubModule = Module:NewModule("SubModule");

I want to do that because sometimes things are getting too big. For example im working on data texts. So I have my main addon and a data texts module. keeping all data texts in that module is way too big so I would like to split them into sub modules.

myrroddin 07-24-19 01:23 PM

From line 221 of AceAddon-3.0:
Lua Code:
  1. -- A module has the same functionality as a real addon, it can have modules of its own, and has the same API as

Lybrial 07-24-19 03:09 PM

Thx. But im getting nil if I do it:

Main Addon:

Lua Code:
  1. LybrialUI = ACE3:NewAddon("Lybrial UI");

MiniMap AddOn:

Lua Code:
  1. LybrialMiniMap = LybrialUI:NewModule("Lybrial MiniMap");
  2. LybrialUI:RegisterModule("Lybrial MiniMap", LybrialMiniMap);

Module of MiniMap:

Lua Code:
  1. Texts = LybrialMiniMap:NewModule("Texts");

SubModule of MiniMap Module:

Lua Code:
  1. Zone = Texts:NewModule("Zone"); -- ERROR: Texts is nil

My import order:

Addon .toc:

Lua Code:
  1. ##################
  2. ## Init
  3. init.lua
  4. ##################
  5.  
  6. ## Modules:
  7. modules\modules.xml

MiniMap .toc:

Lua Code:
  1. ##################
  2. ## Init
  3. init.lua
  4. ##################
  5.  
  6. ## Modules:
  7. modules\modules.xml

MiniMap modules.xml:

xml Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/">
  2.     <Script file="general.lua"/>
  3.     <Script file="appearance.lua"/>
  4.     <Script file="position.lua"/>
  5.     <Script file="clicks.lua"/>
  6.     <Script file="buttons.lua"/>
  7.     <Script file="texts.lua"/>
  8.     <Script file="version.lua"/>
  9.  
  10.     <Script file="texts\init.lua"/>
  11.     <Include file="texts\modules\modules.xml"/>
  12. </Ui>

myrroddin 07-24-19 06:04 PM

  1. What is RegisterModule? NewModule already does that.
  2. In the .tocs of the modules, you are missing a field.
Code:

## RequiredDeps: NameOfCoreAddOn
And if the second module requires the first module, its .toc should read:
Code:

## RequiredDeps: NameOfCoreAddOn, NameOfFirstModule
Next, in your core and modules, if they are their own addons as such with their own .toc files, then don't try to load them via the core addon's .toc.

myrroddin 07-24-19 06:07 PM

SmartRes2 and its Chat Module don't work anymore, but the code examples will still be of help.

Lybrial 07-25-19 04:23 AM

Hi,

ignore RegisterModule. Its stuff that I implemented myself. Should not have posted it.

my core .toc file does not load the modules which are standalone addons.
Core is just the main addon containing core functionality and also general modules.

My other addons have their own .toc file and load their own modules individually.
But everyone of my addons depends on core:

Lua Code:
  1. ## Dependencies: Lybrial_Core

However. Turned out that the Error was missleading and the source of it was something different.
So the the stuff I posted works fine.

Thx


All times are GMT -6. The time now is 03:05 PM.

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