WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Recursing Addons (https://www.wowinterface.com/forums/showthread.php?t=56464)

candrid 07-28-18 09:27 AM

Recursing Addons
 
Hey.

Code:

local Locale = LibStub("AceLocale-3.0"):GetLocale(AddOnName, false);
I get that error when loading into WoW and reloading the UI.

If I understand this right, it should be getting my Addon info from the Addon folder where the TOC is.
I keep all of these Ace Libraries in there own folder that is below the TOC called libraries. I am guessing here, but, I think the code is looking for the addon info in the libraries folder..?

Is it possible to have the "code" look one level up for addon info?

myrroddin 07-28-18 03:11 PM

It sounds like your toc file is not looking for the Lua files in the correct place. Post your entire toc file code, please.

Xrystal 07-28-18 05:36 PM

Quote:

Originally Posted by myrroddin (Post 329128)
It sounds like your toc file is not looking for the Lua files in the correct place. Post your entire toc file code, please.

This is definitely a promising cause to the problem, although I cannot see the error message in your post but if it is the one I have seen a few times since BfA went beta then it appears they have made some adjustments in regards to paths to files in addons.

Rilgamon 07-29-18 02:31 AM

Disable ALL other addons. This way you can be sure your addon loads the required libraries itself and paths are correct. And yes, I had to change some relative paths in my xml files for BfA that worked before.

candrid 08-02-18 08:29 AM

Sorry, I was away.

I will do the requested post when WoW is available to log into. Thank you SO much.

Ok here is the .toc for the main thing.

Code:

## Interface: 80000
## Title: |cffFF9900Paws|r UI
## Notes: A UI for WoW
## Author: Orangepaw3
## X-Website: Offline at the moment.
## X-Favorite-Food: Potatos.
## Version: 2.0
## SavedVariablesPerCharacter: PawDB

# XML Files
##Libraries/Load_Libraries.xml  -- Commented Out due to loading Libraries not working.


# Lua Files
PawsUI.lua
Modules/Features/afk.lua
Modules/Features/gridalign.lua
Modules/Features/level.lua
# Features/panel.lua
# loader.lua


I do not have the XML anymore, I was trying to modulate as much as possible but am having issues getting the items to load with includes and scripts.

Xrystal 08-02-18 10:29 AM

This is how my mage portals addon handles its files. Hopefully it will help you see how it could be done.

TOC
Code:

## Interface: 80100
## Title: XMage : [ |cffeda55fPortals and Teleports|r ]
## Author: Tina Kirby AKA Xrystal (c) 2014-2020  All Rights Reserved
## Version: 8.0.1.27101.0
## Notes: Mage Portals and Teleports Window
## RequiredDeps:
## OptionalDeps:
## DefaultState: Enabled
## LoadOnDemand: 0
## SavedVariables: XMage_Portals_Settings

XMage_Portals.xml

The main XML file - the Frames are configurable and are based on the templates. They share common code and all the files may need access to the data.
Code:

<UI>
    <Script file = "XMage_Portals_Data.lua" />
    <Script file = "XMage_Portals_Code.lua" />
   
    <Include file = "XMage_Portals_Templates.xml" />
    <Include file = "XMage_Portals_Config.xml" />
    <Include file = "XMage_Portals_Frames.xml" />
</UI>

The config.xml file
Code:

<UI>
    <Script file = "XMage_Portals_Config.lua" />
 
    ... One or more frame definitions

</UI>

The frames.xml file - This file is saying that the frames have customization functions ( they are called from other addons and used by the frame as and when it needs to ).
Code:

<UI>
   
    <Script file = "XMage_Portals_Customization.lua" />
    <Script file = "XMage_Portals_Frames.lua" />
   
    ... One or more frame definitions
</UI>

As long as the file that requires functionality of another file is loaded after it will work. If you find that there are sections you are using several times... put it in a file of its own near the beginning so that the rest of the files have access. And if you aren't using it already, don't forget the local addonName, addonData = ... line to allow the files to share the data.

candrid 08-02-18 12:31 PM

Thank you very much!

candrid 08-02-18 05:15 PM

Slightly off-topic.

I was looking at your addon, which is super neat and I noticed there is a bit of code I have been meaning to ask about.

Code:

local addonName, addonData = ...

It's the "..." part. What do they mean? I've read some books with no direct answer.

Also thank you guys for helping me.

Sharparam 08-02-18 05:54 PM

Quote:

Originally Posted by candrid (Post 329266)
It's the "..." part. What do they mean? I've read some books with no direct answer.

When WoW loads a script file it passes two arguments to it: the name of the addon and a private table you can use to store data in (to use across different files). You save them by reading them from the "varargs" passed to the file like in the code above.

The private table can be used to share code/functions across different files without having to create a table that lives in the global namespace, making things cleaner :)

Seerah 08-02-18 07:41 PM

Here is the section in the Lua manual about varargs: https://www.lua.org/pil/5.2.html

candrid 08-03-18 11:37 AM

Quote:

Originally Posted by Seerah (Post 329270)
Here is the section in the Lua manual about varargs: https://www.lua.org/pil/5.2.html

Thank ya muchly!

myrroddin 08-03-18 01:34 PM

Xrystal, might be a silly question, but why did you use 80100 as the Interface in your toc file? We are at least 6-8 months away from that build, if not longer. Right now the current Interface is 80000. Unless you either did a typo, or just used it as an example?


All times are GMT -6. The time now is 01:41 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI