Thread Tools Display Modes
11-19-10, 04:47 AM   #1
Lyelu
A Cyclonian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 44
In-game config panel (breaks on Shared function)

Hi,
I'm adding in a config panel on an oUF layout, and I'm getting stuck because one function will not accept the values from the DB. All the other functions will accept it, but this one makes the entire layout disappear on reload (not loading anything, I think.) I am using Nivea's file to start, because it had all the power bars I wanted. I'm first adding an Ace config and then I will start destroying the layout.

Here's the (shortened) function that will not accept values from my Ace DB. Every other function in the file has no issues:

Code:
local Shared = function(self, unit, isSingle)
	local playerClass = select(2, UnitClass("player"))	
	local unitIsPartyPet = self:GetAttribute("unitsuffix") == "pet"
	self.menu = menu
	self:SetScript("OnEnter", UnitFrame_OnEnter)
	self:SetScript("OnLeave", UnitFrame_OnLeave)
	self:RegisterForClicks"AnyDown"
	
	-- malfunctions here on db value
	if Henna.db.profile.HideBlizzardAuras then
		local BlizzFrame = _G['BuffFrame']
		BlizzFrame:UnregisterEvent('UNIT_AURA')
		BlizzFrame:Hide()
		BlizzFrame = _G['TemporaryEnchantFrame']
		BlizzFrame:Hide()
	end
	
	-- malfunctions here on db value
	local hp = CreateFrame("StatusBar", nil, self)
	hp:SetHeight(Henna.db.profile.heightHP)	
	hp:SetStatusBarTexture(Henna.db.profile.HPtex)
	hp:SetPoint"TOP"
	hp:SetPoint"LEFT"
	hp:SetPoint"RIGHT"
	hp:SetStatusBarColor(unpack(Henna.db.profile.maincolor))
	hp:GetStatusBarTexture():SetHorizTile(true)
	
	hp.frequentUpdates = true
	self.Health = hp
	self.Health.PostUpdate = PostUpdateHealth	
end
This function is referenced later, throughout the file:

Code:
local UnitSpecific = {
	player = function(self, ...)
		Shared(self, ...)
		  -- no issue here with db value
		if Henna.db.profile.useCastbar then	
			createCastbar(self)	
		end
	-- etc etc
	end,			
}
Code:
oUF:RegisterStyle("Henna", Shared)
Is there something about the Shared function that causes it to break whenever I put in values from DB?
Thanks.

Last edited by Lyelu : 11-19-10 at 04:58 AM.
  Reply With Quote
11-19-10, 05:02 AM   #2
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
I suspect a scope issue could be the cause, but without seeing all your code it is difficult to say for certain.
  Reply With Quote
11-19-10, 05:43 AM   #3
Lyelu
A Cyclonian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 44
Here's a paste of the entire file.
http://paste.wowace.com/2881/

Values called cfg are from Nivea's original code. Values called Henna.db.profile are my code.

I have simple things working, like the color picker, but most of my options file right now is just defaults, like so:

Code:
local addon, ns = ...

defaults = {
	profile = {
	maincolor = { r = 0, g = .5, b = 1, a = .5 },
        -- lots more values, this is shortened
	},
}
  Reply With Quote
11-19-10, 07:18 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Install BugSack. I strongly suspect that you'll see some "attempt to index ____ (a nil value)" errors, caused by the fact that when you're spawning your frames, Henna.db has not yet been defined. Try moving your :Spawn calls (basically, everything that's currently inside your oUF:Factory call) into your Henna:OnInitialize() function, after you define the db.
  Reply With Quote
11-20-10, 11:24 AM   #5
Lyelu
A Cyclonian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 44
It does indeed say that. Seems like I have quite a few fights with this "nil value". It's like a bad rogue... constantly following you around trying to Backstab you from the front.

Anyway, so far, the file objects when I move anything around, so perhaps I should start over. Is there an existing oUF layout that uses Ace Config?
  Reply With Quote
11-20-10, 11:54 AM   #6
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Originally Posted by Lyelu View Post
It does indeed say that. Seems like I have quite a few fights with this "nil value". It's like a bad rogue... constantly following you around trying to Backstab you from the front.

Anyway, so far, the file objects when I move anything around, so perhaps I should start over. Is there an existing oUF layout that uses Ace Config?
Not on this site, afaik. You could take a look at oUF_Nivaya. It has a working config for quite some time, Ace free.

E: Another layout with in game config is oUF Lure.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."


Last edited by Dawn : 11-20-10 at 11:58 AM.
  Reply With Quote
11-20-10, 12:21 PM   #7
Lyelu
A Cyclonian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 44
Thanks Dawn. I'd read Nivaya several times, and it was too hard for me, but I think Lure is a great place for me to start. It appears to be written in a way easier for a beginner.
  Reply With Quote
11-20-10, 01:54 PM   #8
lurelure
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 12
Originally Posted by Lyelu View Post
Thanks Dawn. I'd read Nivaya several times, and it was too hard for me, but I think Lure is a great place for me to start. It appears to be written in a way easier for a beginner.
Probably because it's written by a beginner...
I've rewritten it lots of times, and its far from perfect, but i'm quite happy with where it's at now.
  Reply With Quote
11-20-10, 05:33 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
oUF_Phanx also has an in-game config panel, and does not use any Ace3 or other big libraries. (It does use a few "libraries" but they're only libraries because it was the most convenient way for me to share my custom config widget code between my addons.)

But, what you have right now should work, if you do what I suggested in my last post:

Originally Posted by Phanx View Post
Try moving your :Spawn calls (basically, everything that's currently inside your oUF:Factory call) into your Henna:OnInitialize() function, after you define the db.
  Reply With Quote
11-21-10, 02:01 AM   #10
Luzzifus
A Warpwood Thunder Caller
 
Luzzifus's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 94
Originally Posted by lurelure View Post
Probably because it's written by a beginner... I've rewritten it lots of times, and its far from perfect, but i'm quite happy with where it's at now.
I just wanted to answer something semi-nice, but after reading your comment the third or fourth time I realized who you were referring to.

Well, even if you would have referred to me, you would have been at least partially correct. It was basically my first contact with lua and I started off by copying the structure from another layout. I know that my code is not easy to read, and I'm really not proud of many parts. If I'd decide to completely rewrite oUF_Nivaya (which I probably never will do), I'd do many things differently.

PS: oUF_Nivaya does use AceConfig.

Last edited by Luzzifus : 11-21-10 at 02:06 AM.
  Reply With Quote
11-21-10, 12:17 PM   #11
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
Originally Posted by Luzzifus View Post
PS: oUF_Nivaya does use AceConfig.
Oh, didn't know that. I haven't looked at your code, yet. I stand corrected.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
11-21-10, 12:51 PM   #12
Lyelu
A Cyclonian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 44
Post

Well I finally got some basics working... Nivaya's code wasn't possible for me to imitate because it just uses more things than I know yet. But having read all of yours several times, I have finally managed to get a health statusbar up on the screen. I had quite a time with the loading orders etc.

Edit: Deleted a question here, because I found a workaround.

Last edited by Lyelu : 11-22-10 at 12:52 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » In-game config panel (breaks on Shared function)


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