Thread Tools Display Modes
08-02-11, 02:56 PM   #1
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
Question Config help!

I'm trying to make a Config file in lua for my addon but having problems on setting the point. I got the scale to work but that's all I know how to do. This is what I have been trying.

Config.lua
Code:
local _, DreamTweaks = ...

DreamTweaks.Config = {

    MainMenuBar = {
        scale = 1,
	["Position"] = { a= "BOTTOMLEFT", Minimap, x= -515, y= -4}

    },
}
ActionBars.lua
Code:
local _, DreamTweaks = ...
local cfg = DreamTweaks.Config

local function ActionBars()

    MainMenuBar:ClearAllPoints()
    MainMenuBar:SetPoint(cfg.MainMenuBar.["Position"])

end

local function Start()
	hooksecurefunc("UIParent_ManageFramePositions",ActionBars);
	MainMenuBar:SetScale(cfg.MainMenuBar.scale)

    ActionBars();

end

	Start()
I'm completely lost. Been goggling for info and going over others addons but I can't find anything. Can someone pleas help point me in the right direction I want to learn how to do all of this.
Thank you.
  Reply With Quote
08-02-11, 03:01 PM   #2
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
It's a table, so you need to unpack it.

Code:
MainMenuBar:SetPoint(unpack(cfg.MainMenuBar.Position))
However, to do that, you'll need to change your table slightly so it only contains the raw data.

Code:
["Position"] = { "BOTTOMLEFT", Minimap, -515, -4}
  Reply With Quote
08-02-11, 03:07 PM   #3
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Your MainMenuBar:SetPoint(cfg.MainMenuBar.["Position"]) would have to be spelled out to match the table, or place the table into it which doesn't line up if you have a value of a table into a table.

For example your

Code:
["Position"] = { a= "BOTTOMLEFT", Minimap, x= -515, y= -4}
Should look like this

Code:
["Position"] = { a= "BOTTOMLEFT",p= Minimap, r="CENTER", x= -515, y= -4}
Adding a 'p' for parent and an 'r' for relative point which is needed for SetPoint.

You'd also have to have your SetPoint look like this:

Code:
MainMenuBar:SetPoint(cfg.MainMenuBar.["Position"].a,cfg.MainMenuBar.["Position"].p,cfg.MainMenuBar.["Position"].r,cfg.MainMenuBar.["Position"].x,cfg.MainMenuBar.["Position"].y)
This can be simplified by just changing cfg.MainMenubar.["Position"] to a local.

Code:
local db = cfg.MainMenuBar.["Position"]
MainMenuBar:SetPoint(db.a,db.p,db.r,db.x,db.y)
  Reply With Quote
08-02-11, 03:22 PM   #4
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
suicidalkatt, I'm still getting error

Code:
Message: Interface\AddOns\DreamTweaks\ActionBars.lua:22: '<name>' expected near '['
Time: 08/02/11 14:20:31
Count: 1
Stack: 
Locals:
  Reply With Quote
08-02-11, 03:26 PM   #5
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
Originally Posted by suicidalkatt View Post
You'd also have to have your SetPoint look like this:

Code:
MainMenuBar:SetPoint(cfg.MainMenuBar.["Position"].a,cfg.MainMenuBar.["Position"].p,cfg.MainMenuBar.["Position"].r,cfg.MainMenuBar.["Position"].x,cfg.MainMenuBar.["Position"].y)
Should be:

lua Code:
  1. MainMenuBar:SetPoint(cfg.MainMenuBar["Position"].a,cfg.MainMenuBar["Position"].p,cfg.MainMenuBar["Position"].r,cfg.MainMenuBar["Position"].x,cfg.MainMenuBar["Position"].y)
or
lua Code:
  1. MainMenuBar:SetPoint(cfg.MainMenuBar.Position.a, cfg.MainMenuBar.Position.p, cfg.MainMenuBar.Position.r, cfg.MainMenuBar.Position.x, cfg.MainMenuBar.Position.y)
__________________
  Reply With Quote
08-02-11, 03:29 PM   #6
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
Originally Posted by Haleth View Post
It's a table, so you need to unpack it.

Code:
MainMenuBar:SetPoint(unpack(cfg.MainMenuBar.Position))
However, to do that, you'll need to change your table slightly so it only contains the raw data.

Code:
["Position"] = { "BOTTOMLEFT", Minimap, -515, -4}
I must have missed something the first time I tried your code but now it works and yours is more simple then the others. Thank you.

And thank you to all the rest of you for helping me so fast love you all.
  Reply With Quote
08-02-11, 04:03 PM   #7
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 331
Originally Posted by Mischback View Post
Should be:

lua Code:
  1. MainMenuBar:SetPoint(cfg.MainMenuBar["Position"].a,cfg.MainMenuBar["Position"].p,cfg.MainMenuBar["Position"].r,cfg.MainMenuBar["Position"].x,cfg.MainMenuBar["Position"].y)
or
lua Code:
  1. MainMenuBar:SetPoint(cfg.MainMenuBar.Position.a, cfg.MainMenuBar.Position.p, cfg.MainMenuBar.Position.r, cfg.MainMenuBar.Position.x, cfg.MainMenuBar.Position.y)
Sorry used some quick replacing. * Derp dance *
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » 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