Thread Tools Display Modes
08-25-11, 08:17 PM   #1
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
Config.lua to ingame GUI?

Ok so I have been trying for weeks to make a in game GUI with no luck. I was hopping to do this just with lua code and no libs.
I tried looking into doing it with Ace3 but I can't understand all that has to be done and were to place the code. I added my SavedVariables field to my TOC, put all my settings into a single table. That's as far as I can get with out then getting completely lost.

Her is all of my code.

http://www.wowace.com/paste/3767/

O also when using Ace3 were do I put the files and which ones do I use, or do I just place the whole Ace3 file in the addons?

Last edited by dreamcatcher : 08-25-11 at 08:21 PM.
  Reply With Quote
08-27-11, 02:47 AM   #2
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
So i finely got the GUI to show up but im getting lots of errors.

Code:
Message: Interface\AddOns\Tweaks\Core.lua:536: attempt to index upvalue 'db' (a nil value)
Time: 08/27/11 01:47:06
Count: 1
Stack: Interface\AddOns\Tweaks\Core.lua:536: in function <Interface\AddOns\Tweaks\Core.lua:534>
[C]: in function `UIParent_ManageFramePositions'
Interface\FrameXML\InterfaceOptionsPanels.lua:1284: in function `InterfaceOptions_UpdateMultiActionBars'
[string "*:OnLoad"]:4: in function `setFunc'
Interface\FrameXML\InterfaceOptionsPanels.lua:1253: in function <Interface\FrameXML\InterfaceOptionsPanels.lua:1246>

Locals: (*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to index upvalue 'db' (a nil value)"
db = nil
Here is link to whole code.
http://www.wowace.com/paste/3784/
  Reply With Quote
08-27-11, 03:00 AM   #3
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
First, I don't see you declaring your addon at the very top in Ace fashion. Ie:

Core.lua
Code:
local MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
Config.lua
Code:
local MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")

For getting DB, you'll want to put this line in:
Code:
self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults, "Default")
I generally put my defaults table in Core.lua, along with the above line in the MyAddon:OnInitialize() function. MyAddonDB is the SavedVariable table name declared in .toc, and Default is the name of your initial profile.

To get the DB into a variable, something like this in a MyAddon:Anything() function.
Code:
db = self.db.profile

O also when using Ace3 were do I put the files and which ones do I use, or do I just place the whole Ace3 file in the addons?
For now, you can just install Ace3 like a regular addon, this will ensure you have all the components necessary. When you finalize your addon later on, you can set up dependencies and an Embeds.xml, as well as store required Ace folders inside your addon.

Last edited by Nibelheim : 08-27-11 at 03:21 AM.
  Reply With Quote
08-27-11, 03:18 AM   #4
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Here's some quick examples of a basic Ace addon. You can install Ace3 components under MyAddon\libs\

MyAddon.toc
Embeds.xml
Core.lua
Config.lua

Last edited by Nibelheim : 08-27-11 at 03:26 AM.
  Reply With Quote
08-28-11, 03:48 AM   #5
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
First thank you for your help, I got the options to show up now and there are no errors.
Now I'm trying to set up all the functions and I'm having some problems.
  1. One
I don't know how to set it so I can have the option to re position the bars. My code for that is this.

Core.lua
Code:
local defaults = {
	profile = {
		MAB = {
			Enable = true,
			HideMacronames = true,
			HideGryphons = false,
			Scale = .8,
			["Position"] = {"BOTTOMLEFT",Minimap,-510,0},
		},

local function ActionBars()

-- MainActionBar
	for i = 1, 12 do
		local MAB = _G["ActionButton"..i]
		if (i == 1) then
        MAB:ClearAllPoints()
        MAB:SetPoint(unpack(db.MAB.Position))
		MAB:SetScale(db.MAB.Scale)
	else
        MAB:ClearAllPoints()
        MAB:SetPoint("LEFT", _G["ActionButton"..i-1],"RIGHT",6,0)
		MAB:SetScale(db.MAB.Scale)
		end
	end
Config.lua
Code:
MAB = {
	name = "MainActionBar",
	type = "group",
	order = 30,
	args = {
		Position= {
			type = "input",
			name = "Position",
			order = 1,
			set = function(info, val)
			db.MAB.Position = val
			MyAddon:UpdateStuff()
			end,
			get = function(info) return db.MAB.Position end,
		},
         },
  1. Second
I can get the end caps to show and hide but I can't get the micro names to do the same.

Core.lua
Code:
function Style(self)  
	local name = self:GetName()
	local action = self.action
	local Button = self
	local Count = _G[name.."Count"]
	local HotKey = _G[name.."HotKey"]
	local Border  = _G[name.."Border"]
	local Btname = _G[name.."Name"]
	local Normal  = _G[name.."NormalTexture"]
Btname:Show()
	Button:SetNormalTexture[[Interface\AddOns\MyAddon\Media\button]]
	Border:Hide()
	if db.MAB.HideMacronames then
	Btname:Hide()
	end
end
Config.lua
Code:
HideMacronames = {
	type = "toggle",
	name = "HideMacronames",
	order = 2,
	set = function(info, val)
	db.MAB.HideMacronames = val
	MyAddon:UpdateStuff()
	end,
	get = function(info) return db.MAB.HideMacronames end,
},
  Reply With Quote
08-28-11, 01:16 PM   #6
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by dreamcatcher View Post
First thank you for your help, I got the options to show up now and there are no errors.
Now I'm trying to set up all the functions and I'm having some problems.
  1. One
I don't know how to set it so I can have the option to re position the bars. My code for that is this.

Core.lua
Code:
local defaults = {
	profile = {
		MAB = {
			Enable = true,
			HideMacronames = true,
			HideGryphons = false,
			Scale = .8,
			["Position"] = {"BOTTOMLEFT",Minimap,-510,0},
		},

local function ActionBars()

-- MainActionBar
	for i = 1, 12 do
		local MAB = _G["ActionButton"..i]
		if (i == 1) then
        MAB:ClearAllPoints()
        MAB:SetPoint(unpack(db.MAB.Position))
		MAB:SetScale(db.MAB.Scale)
	else
        MAB:ClearAllPoints()
        MAB:SetPoint("LEFT", _G["ActionButton"..i-1],"RIGHT",6,0)
		MAB:SetScale(db.MAB.Scale)
		end
	end
Config.lua
Code:
MAB = {
	name = "MainActionBar",
	type = "group",
	order = 30,
	args = {
		Position= {
			type = "input",
			name = "Position",
			order = 1,
			set = function(info, val)
			db.MAB.Position = val
			MyAddon:UpdateStuff()
			end,
			get = function(info) return db.MAB.Position end,
		},
         },
  1. Second
I can get the end caps to show and hide but I can't get the micro names to do the same.

Core.lua
Code:
function Style(self)  
	local name = self:GetName()
	local action = self.action
	local Button = self
	local Count = _G[name.."Count"]
	local HotKey = _G[name.."HotKey"]
	local Border  = _G[name.."Border"]
	local Btname = _G[name.."Name"]
	local Normal  = _G[name.."NormalTexture"]
Btname:Show()
	Button:SetNormalTexture[[Interface\AddOns\MyAddon\Media\button]]
	Border:Hide()
	if db.MAB.HideMacronames then
	Btname:Hide()
	end
end
Config.lua
Code:
HideMacronames = {
	type = "toggle",
	name = "HideMacronames",
	order = 2,
	set = function(info, val)
	db.MAB.HideMacronames = val
	MyAddon:UpdateStuff()
	end,
	get = function(info) return db.MAB.HideMacronames end,
},
dreamcatcher im getting close maybe something in my code will help you solve your issue.

Post from wowace.com
WOOT!!



ok so i have my options in game now and its almost working right LOL.

Issues are:

1) does not load default setting to start yet in the options everything is checked. (see screenshot)

2) does not save option changes.

Here are my core.lua and config.lua for you to look at (fair warning the core is huge) did i do forget something did i add something i shouldn't have.

Any Help would be great.

And thank you to everyone who as helped me with the long process.

Coke
Hopefully we both can be up and running soon... havent played WoW in a week been to obsessed with getting this to work LOL

Hope this helps ya.

Coke
  Reply With Quote
08-28-11, 01:48 PM   #7
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
I to have not played wow in two weeks been like you say obsessed with my coding

I have been looking at your stuff on the WowAce Forums. But yours is so so so much bigger then mine that i get lost in your code. Also you don't have any gui command for positions.
  Reply With Quote
08-28-11, 03:20 PM   #8
dreamcatcher
A Black Drake
 
dreamcatcher's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2010
Posts: 82
Woot figured out how to change position of bar.

Config.lua
Code:
        offsetX = {
		name = "X Offset",
		type = "input",
		width = "half",
		order = 13,
		desc = "Offsets from the tooltip's anchor left/right",
		set = function(info, value)
		db.MAB.offsetX = value
		MyAddon:UpdateStuff()
		end,
		get = function(info) return tostring(db.MAB.offsetX) end,
	},
	offsetY = {
		name = "Y Offset",
	        type = "input",
		width = "half",
		order = 14,
		desc = "Offsets from the anchor up/down",
		set = function(info, value)
		db.MAB.offsetY = value
		MyAddon:UpdateStuff()
		end,
		get = function(info) return tostring(db.MAB.offsetY) end,
	},
	anchor = {
		name = "Anchor To...",
		type = "select",
		order = 11,
		desc = "What side of the screen you would like the located at.",
		values = positions,
		set = function(info, value)
		db.MAB.anchor = positions[value]
		MyAddon:UpdateStuff()
		end,
		get = function()
        	     for k, v in pairs(positions) do
        	         if v == db.MAB.anchor then
		        	return k
			end
        	     end
		end,
	},
Core.lua
Code:
local defaults = {
	profile = {
		MAB = {
			Enable = true,
			HideMacronames = true,
			HideGryphons = false,
			Scale = .8,
			anchor = "BOTTOMLEFT",
			offsetX = "-510",
			offsetY = "0",
		},

-- MainActionBar
	for i = 1, 12 do
		local MAB = _G["ActionButton"..i]
		if (i == 1) then
        MAB:ClearAllPoints()
        MAB:SetPoint(db.MAB.anchor, Minimap, db.MAB.anchor, db.MAB.offsetX, db.MAB.offsetY)
		MAB:SetScale(db.MAB.Scale)
	else
        MAB:ClearAllPoints()
        MAB:SetPoint("LEFT", _G["ActionButton"..i-1],"RIGHT",6,0)
		MAB:SetScale(db.MAB.Scale)
		end
	end
Now still need to figure out how to get the micro names to show and hide.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Config.lua to ingame GUI?


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