WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Multiple Addon's One User Config (https://www.wowinterface.com/forums/showthread.php?t=44818)

cokedrivers 10-17-12 07:05 PM

Multiple Addon's One User Config
 
I'm trying to create a single .lua file that will transfer my personal config changes to Neav UI with its 10 seperate addons used. I think I'm close but I think it fires to soon for it to change the settings.

Below is my .lua if someone could give me a little help this would be great.


Thanks in advance.

Coke


Here is the file:

Code:

local _, nExtras = ...
local cfg = nExtras.Config

-- This is for a custom config profile of the Neav UI Addon's
-- here you can change setting with any nAddon
-- so when updateing to a newer version you can
-- keep your personal settings you like. Unless the Config has changed

-- Make sure when adding config options that it is case sensitive so make it match.

-- Examples for this area would be: nMainbar.Config.MainMenuBar.ShortBar = false


local _, nBuff = ...        -- Config Table for nBuff
local _, nChat = ...        -- Config Table for nChat
local _, nData = ...        -- Config table for nData
local _, nMainbar = ...        -- Config table for nMainbar
local _, nMinimap = ...        -- Config Table for nMinimap
local _, nPlates = ...        -- Config Table for nPlates
local _, nPower = ...        -- Config Table for nPower
local _, nTooltip = ...        -- Config Table for nTooltip
local _, ns = ...        -- Config Table for oUF_Neav and oUF_NeavRaid
               
if cfg.NCP ~= true then return end

local f = CreateFrame("Frame")

function f:PROFILE()
        -- nBuff Customization's
        if (IsAddOnLoaded("nBuff")) then
                nBuff.Config = {
                        buffSize = 50,
                }
        end

        -- nChat Customization's
        if (IsAddOnLoaded("nChat")) then
                nChat.Config = {
               
                }       
        end

        -- nData Customization's
        if (IsAddOnLoaded("nData")) then
                nData.Config = {
               
                }
        end
               
        -- nMainbar Customization's
        if (IsAddOnLoaded("nMainbar")) then
                nMainbar.Config = {
                        shortBar = true,
                }
        end

        -- nMinimap Customization's
        if (IsAddOnLoaded("nMinimap")) then
                nMinimap.Config = {
               
                }
        end

        -- nPlates Customization's
        if (IsAddOnLoaded("nPlates")) then
                nPlates.Config = {
               
                }
        end

        -- nPower Customization's
        if (IsAddOnLoaded("nPower")) then
                nPower.Config = {
               
                }
        end

        -- nTooltip Customization's
        if (IsAddOnLoaded("nTooltip")) then
                nTooltip.Config = {
               
                }
        end

        -- oUF_Neav Customization's
        if (IsAddOnLoaded("oUF_Neav")) then
                ns.Config = {
               
                }
        end

        -- oUF_NeavRaid Customization's
        if (IsAddOnLoaded("oUF_NeavRaid")) then
                ns.Config = {
               
                }
        end
end

if (event == "PLAYER_LOGIN") then
        f:PROFILE()
end
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("PROFILE")


Barjack 10-17-12 09:18 PM

I can't speak for the overall functionality but the way you are using so many "local _, nWhatever = ..." statements appears very odd to me.

When you use ... outside of a function like that, it is returning is the addon name and a table specific to that addon. In other words, in your code, locals like nBuff, nChat, nData etc. are all being set to the same table, and probably not the table you expect.

There's nothing magic about ... where you can pull out whatever table you like, but rather, it is a convention used on a per-addon basis to create a sort of table namespace for that specific addon. I don't know where you've put this .lua file (perhaps in nExtras) but the one and only table you are going to get out of ... is the one for that addon. Copying that ... line out from another addon won't give you access to that addon's table. So if you need access to other tables, you need to access them as globals or however else they are exposed.


All times are GMT -6. The time now is 06:51 AM.

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