Thread Tools Display Modes
04-08-12, 10:53 AM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Ace Config Help...

Hello, I'm trying to switch a current config over to Ace3.

So here is the issue, i can not figure out how to put a [2] into the config options below is the codes I'm trying to use.


.lua Code
Code:
local ComboColor = C['power'].energy.comboColor
local function SetComboColor(i)
    local comboPoints = GetComboPoints('player', 'target') or 0
	
    if (i > comboPoints or UnitIsDeadOrGhost('target')) then
        return 1, 1, 1
    else
        return ComboColor[i].r, ComboColor[i].g, ComboColor[i].b
    end
end
Config Code
Code:
C['power'] = {
    energy = {
        comboColor = {
            [1] = {r = 1.0, g = 1.0, b = 1.0},	-- Combo Point #1
            [2] = {r = 1.0, g = 1.0, b = 1.0},	-- Combo Point #2
            [3] = {r = 1.0, g = 1.0, b = 1.0},	-- Combo Point #3
            [4] = {r = 0.9, g = 0.7, b = 0.0},	-- Combo Point #4
            [5] = {r = 1.0, g = 0.0, b = 0.0},	-- Combo Point #5
        },		
    },
}
Now in the Ace3 Config It will not let me just do
Code:
 
[1] = {
   order = 8,
   type = "color",
   name = L["ComboPoint 1 Color"],
   hasAlpha = false,
   disabled = function() return not db.mainbar.enable end,
   get = function(info)
	local hb = db.power.energy[ info[#info] ]
	return hb.r, hb.g, hb.b
	end,
   set = function(info, r, g, b)
	db.power.energy[ info[#info] ] = {}
	local hb = db.power.energy[ info[#info] ]
	hb.r, hb.g, hb.b = r, g, b
	StaticPopup_Show("CFG_RELOAD") 
  end,					
},
So my question is without rewriting this whole thing how do i set it up for Ace3?

Any Help with this would be great.

Thanks
Coke
  Reply With Quote
04-08-12, 11:04 AM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Code:
set = function(info, r, g, b)
	db.power.energy[ info[#info] ] = {}
	local hb = db.power.energy[ info[#info] ]
	hb.r, hb.g, hb.b = r, g, b
	StaticPopup_Show("CFG_RELOAD") 
end,
This line looks a bit odd, since I don't recall you had to create a new table, instead of just modifying the table (provided you passed your defaults to AceDB)

There might be other stuff that are wrong, but just pointing out that part

Last edited by Ketho : 04-08-12 at 11:09 AM.
  Reply With Quote
04-08-12, 11:22 AM   #3
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Ketho View Post
Code:
set = function(info, r, g, b)
	db.power.energy[ info[#info] ] = {}
	local hb = db.power.energy[ info[#info] ]
	hb.r, hb.g, hb.b = r, g, b
	StaticPopup_Show("CFG_RELOAD") 
end,
This line looks a bit odd, since I don't recall you had to create a new table, instead of just modifying the table (provided you passed your defaults to AceDB)

There might be other stuff that are wrong, but just pointing out that part
Forgot to mention this code does work for other color changes just not the ones i need with the [1] (numbers) for instance

Code:
	
buffBorderColor = {
	order = 3,
	type = "color",
	name = L["Buff Border Color"],
	hasAlpha = false,
	disabled = function() return not db.buff.enable end,
	get = function(info)
	    local hb = db.buff[ info[#info] ]
	    return hb.r, hb.g, hb.b
	end,
	set = function(info, r, g, b)
	    db.buff[ info[#info] ] = {}
	    local hb = db.buff[ info[#info] ]
	    hb.r, hb.g, hb.b = r, g, b
	    StaticPopup_Show("CFG_RELOAD") 
	end,					
},
works just fine.

I'm still learning and teaching myself .lua.

No schooling ever with codeing so for now its pretty my copy paste and a little tweeking. I know alot of people wont help unless the person doing it wrote the code.

So either one of 3 things will happen
A) like normal I will get told to "Go Read".
B) this post will get ignored.
C) Someone will help out.

But thanks you for pointing out issues with the codeing cause one year I will have this figured out and do it all myself.

Coke
  Reply With Quote
04-08-12, 10:05 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
1. Please post the error messages you are getting if some code "doesn't work", or at least be more specific about what "doesn't work", or about what "it" is and what it "won't let you" do.

2. AceConfig table keys (eg. the option name) must be strings. They cannot be numbers.
  Reply With Quote
04-10-12, 02:19 PM   #5
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
I just made it simple like:
Code:
local ComboColor = {
    [1] = {r = 1.0, g = 1.0, b = 1.0},
    [2] = {r = 1.0, g = 1.0, b = 1.0},
    [3] = {r = 1.0, g = 1.0, b = 1.0},
    [4] = {r = 0.9, g = 0.7, b = 0.0},
    [5] = {r = 1.0, g = 0.0, b = 0.0},
}
in the Code instead of haveing it in the Config.

Thanks for posts.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Ace Config Help...


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off