Thread Tools Display Modes
10-16-08, 02:04 PM   #101
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by p3lim View Post
The order of the if checks etc matters
Yeah but that's the only order i came up with so the pet's name was happiness colored, how would you sort them then ?
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
 
10-16-08, 03:02 PM   #102
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Finally online, so here's the report

Code:
Interface\AddOns\oUF_Caellian\oUF_Caellian.lua:112: bad argument #1 to 'unpack' (table expected, got nil)
Count: 3

Call Stack:
[C]: ?
[C]: in function `unpack'
Interface\AddOns\oUF_Caellian\oUF_Caellian.lua:112: in function `UNIT_NAME_UPDATE'
Interface\AddOns\oUF_Caellian\oUF_Caellian.lua:167: in function `PostUpdateHealth'
Interface\AddOns\oUF\elements\health.lua:96: in function `UNIT_MAXHEALTH'
Interface\AddOns\oUF\elements\health.lua:43: in function <Interface\AddOns\oUF\elements\health.lua:35>
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
 
10-16-08, 03:08 PM   #103
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Take a look at how oUF does and steal the code it uses .
 
10-16-08, 03:13 PM   #104
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Caellian View Post
Finally online, so here's the report

Code:
Interface\AddOns\oUF_Caellian\oUF_Caellian.lua:112: bad argument #1 to 'unpack' (table expected, got nil)
Count: 3

Call Stack:
[C]: ?
[C]: in function `unpack'
Interface\AddOns\oUF_Caellian\oUF_Caellian.lua:112: in function `UNIT_NAME_UPDATE'
Interface\AddOns\oUF_Caellian\oUF_Caellian.lua:167: in function `PostUpdateHealth'
Interface\AddOns\oUF\elements\health.lua:96: in function `UNIT_MAXHEALTH'
Interface\AddOns\oUF\elements\health.lua:43: in function <Interface\AddOns\oUF\elements\health.lua:35>
I don't know whats wrong with your code but I would debug to find out DEFAULT_CHAT_FRAME:AddMessage() is your friend.

One thing I have noticed though is
Code:
color = {r, g, b} or self.colors.health
will always cause color to be set to {r,g,b} as a table is always present.
 
10-16-08, 03:18 PM   #105
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by haste View Post
Take a look at how oUF does and steal the code it uses .
Well then that should be something like this but it still doesn't work.

Code:
local function OverrideUpdateName(self, event, unit)
	if(self.unit ~= unit) then return end

	if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
		color = self.colors.tapped
	elseif(UnitIsDead(unit) or UnitIsGhost(unit) or not UnitIsConnected(unit)) then
		color = self.colors.disconnected
	elseif(unit =='pet') then
		color = self.colors.happiness[GetPetHappiness()] or self.colors.power[UnitPowerType(unit)]
	elseif(UnitIsPlayer(unit)) then
		local _, class = UnitClass(unit)
		color = self.colors.class[class] or self.colors.disconnected
	else
		local r, g, b = UnitSelectionColor(unit)
		color = {r, g, b} or self.colors.health
	end

	self.Name:SetTextColor(unpack(color))
Any help?
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
 
10-16-08, 03:26 PM   #106
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
This is the exact function in oUF:
Code:
		local r, g, b, t
		if(bar.colorTapping and UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
			t = self.colors.tapped
		elseif(bar.colorDisconnected and not UnitIsConnected(unit)) then
			t = self.colors.disconnected
		elseif(bar.colorHappiness and unit == "pet" and GetPetHappiness()) then
			t = self.colors.happiness[GetPetHappiness()]
		elseif(bar.colorClass and UnitIsPlayer(unit)) or (bar.colorClassNPC and not UnitIsPlayer(unit)) then
			local _, class = UnitClass(unit)
			t = self.colors.class[class]
		elseif(bar.colorReaction) then
			r, g, b = UnitSelectionColor(unit)
		elseif(bar.colorSmooth and max ~= 0) then
			r, g, b = self.ColorGradient(min / max, unpack(bar.smoothGradient or self.colors.smooth))
		elseif(bar.colorHealth) then
			t = self.colors.health
		end

		if(t) then
			r, g, b = t[1], t[2], t[3]
		end

		if(b) then
			bar:SetStatusBarColor(r, g, b)

			local bg = bar.bg
			if(bg) then
				local mu = bg.multiplier or 1
				bg:SetVertexColor(r * mu, g * mu, b * mu)
			end
		end
Notice how it always validates that it has the color data before it tries to use it .

A couple of tips:
- X or Y structures should be avoided due to readability, and it's obviously biting you here.
- You should not make your function expect a table, to then unpack it, but rather do it yourself.
- You shouldn't create a new table on every update like you do now. {r, g, b} creates one every time.

Also note the following:
Code:
Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> return {}
{}
> return {r, g, b}
{}
> -- This is because:
> return {nil, nil, nil}
{}
> return {} or 1
{}
> -- As a bonus:
> return {nil, 1, nil}
{2=1}
 
10-16-08, 06:14 PM   #107
Blt
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 2
I have two questions, and please forgive me i'm very new to the WoW API:

First, is there any way to change the zorder and color on your edge file?
I looked on wowwiki at the API for SetBackDrop and the entry on edgefiles and there didn't seem to be an easy way?
As it is right now, the contents of my unitframes completely cover the border that is drawn. I'd like that to be reversed, and i'd like it to be unit coloured.

Also, how do I go about turning off tooltips when in combat, I assume it involved using the IsCombatLocked() function, but i'm not sure, as it doesn't seem to fire whereever I put it.
 
10-17-08, 01:46 AM   #108
Cala
A Fallenroot Satyr
 
Cala's Avatar
AddOn Compiler - Click to view compilations
Join Date: Jan 2007
Posts: 22
So with 3.0.2 basically frying every single one of my neural synapses (horray for no mounts other than your AQ bug!), I committed the cardinal sin of not backing up my addons before making changes. (Bad me, I know, I know.)

So I had to start from scratch with oUF. And I need my raid frames replaced. I figured this out once before, but like an idiot, I forgot to remember how I did it.

Hence I am humbly asking for help. I need to take this code:

Code:
local Raid = {}
for i = 1, NUM_RAID_GROUPS do
	local RaidGroup = oUF:Spawn("header", "oUF_Raid" .. i)
	RaidGroup:SetAttribute("groupFilter", tostring(i))
	RaidGroup:SetAttribute("showRaid", true)
	RaidGroup:SetAttribute("yOffset", -10)
	RaidGroup:SetAttribute("point", "TOP")
	RaidGroup:SetAttribute("showRaid", true)
	table.insert(Raid, RaidGroup)
	if i == 1 then
		RaidGroup:SetPoint("TOPLEFT", UIParent, 35, -35) 
	else
		RaidGroup:SetPoint("TOPLEFT", Raid[i-1], "TOPRIGHT", 10, 0)	
	end
	RaidGroup:Show()
end
And move the raid frames down (I do know how to do that...) but also to re-'break' the raid frames.

I know that I need to do

[/code]
for i = 1, NUM_RAID_GROUPS do
[/code]

to

[/code]
for i = 1, 5 do
[/code]

to get the full 25 in the center of my screen.

But now I'm lost. I'm pretty sure that I need to change

Code:
if i == 1 then
		RaidGroup:SetPoint("TOPLEFT", UIParent, 35, -35) 
	else
		RaidGroup:SetPoint("TOPLEFT", Raid[i-1], "TOPRIGHT", 10, 0)	
	end
	RaidGroup:Show()
end
to

Code:
if i == 6 then
                RaidGroup:SetPoint(side of the screen!)
elseif i == 7 then
                 RaidGroup:SetPoint(still on the side)
elseif i == 8 then
                 RaidGroup:SetPoint(and on the side still)
       end 
       RaidGroup:Show()
end
But when I tried it earlier tonight, it broke all the frames. =\ Did I not remember correctly and do it wrong?
 
10-17-08, 02:06 AM   #109
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
I've tried to understand and follow your advices

This one is working, exept for warlock pets, at least there's no error anymore.
I didn't manage to add another working 'if' so the warlock pets would be colored with (for example) the warlock color class.
If you could take a look and tell me how to fix it once and for all please.

Code:
local function OverrideUpdateName(self, event, unit)
--	if(self.unit ~= unit) then return end

	local r, g, b, t
	if(UnitIsTapped(unit) and not UnitIsTappedByPlayer(unit)) then
		t = self.colors.tapped
	elseif(UnitIsDead(unit) or UnitIsGhost(unit) or not UnitIsConnected(unit)) then
		t = self.colors.disconnected
	elseif(unit =='pet' and GetPetHappiness()) then
		t = self.colors.happiness[GetPetHappiness()]
	elseif(not UnitIsPlayer(unit)) then
		r, g, b = UnitSelectionColor(unit)
--		color = {r, g, b} or self.colors.health
	else
		local _, class = UnitClass(unit)
		t = self.colors.class[class] or self.colors.disconnected
	end

	if(t) then
		r, g, b = t[1], t[2], t[3]
	end

	self.Name:SetTextColor(r, g, b)
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }

Last edited by Caellian : 10-17-08 at 07:00 AM.
 
10-17-08, 07:55 AM   #110
Bruners
A Flamescale Wyrmkin
 
Bruners's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 125
Im trying to show combopoints with a texture instead of just text, i have this code but cant seem to get it to work.

Code:
if unit=="target" and playerClass == "ROGUE" or playerClass == "DRUID" then
	local cparr = {}
	for i=0,5 do
		cparr[i] = self:CreateTexture"Interface\\Addons\\oUF_Brun\\textures\\combo"
			if(i == 0) then
				cparr[i]:SetPoint("TOPLEFT", self, "TOPRIGHT", 20)
			else
				cparr[i]:SetPoint("TOP", cparr[i-1], "BOTTOM")
			end
	end
	self.CPoints = cparr
end
any tips ?
 
10-17-08, 07:57 AM   #111
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Bruners View Post
Im trying to show combopoints with a texture instead of just text, i have this code but cant seem to get it to work.

Code:
if unit=="target" and playerClass == "ROGUE" or playerClass == "DRUID" then
	local cparr = {}
		for i=0,5 do
			cparr[i] = self:CreateTexture"Interface\\Addons\\oUF_Brun\\textures\\combo"
				if(i == 0) then
					cparr[i]:SetPoint("TOPLEFT", self, "TOPRIGHT", 20)
				else
					cparr[i]:SetPoint("TOP", cparr[i-1], "BOTTOM")
					end
		end
	self.CPoints = cparr
end
any tips ?
the createstyle function will never accept updates
 
10-17-08, 11:10 AM   #112
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by Bruners View Post
Im trying to show combopoints with a texture instead of just text, i have this code but cant seem to get it to work.

Code:
if unit=="target" and playerClass == "ROGUE" or playerClass == "DRUID" then
	local cparr = {}
	for i=0,5 do
		cparr[i] = self:CreateTexture"Interface\\Addons\\oUF_Brun\\textures\\combo"
			if(i == 0) then
				cparr[i]:SetPoint("TOPLEFT", self, "TOPRIGHT", 20)
			else
				cparr[i]:SetPoint("TOP", cparr[i-1], "BOTTOM")
			end
	end
	self.CPoints = cparr
end
any tips ? :)
1. There's only five points, you create six. 0, 1, 2, 3, 4, 5.
2. You don't give them a height.
3. Ignore whatever p3lim tried to said.
4. Your indenting sucks :p.
 
10-17-08, 12:42 PM   #113
Bruners
A Flamescale Wyrmkin
 
Bruners's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 125
Got to this now, no idea if its correct
my indent looks good :P
Code:
if unit=="target" and playerClass == "ROGUE" or playerClass == "DRUID" then
	local cparr = {}
	for i=0,4 do
		cparr[i] = self:CreateTexture("Interface\\Addons\\oUF_Brun\\textures\\combo")
		cparr[i]:SetHeight(10)
		cparr[i]:SetWidth(10)
		if(i == 0) then
			cparr[i]:SetPoint("TOPLEFT", self, "TOPRIGHT", 20)
		else
			cparr[i]:SetPoint("TOP", cparr[i-1], "BOTTOM")
		end
	end
	self.CPoints = cparr
end
but getting errors from cpoints.lue

Code:
[2008/10/17 20:34:42-634-x1]: oUF-1.2.1\elements\cpoints.lua:21: attempt to index field '?' (a nil value)
oUF-1.2.1\ouf.lua:339: in function <Interface\AddOns\oUF\ouf.lua:333>
<in C code>: in function `Show'
Interface\FrameXML\SecureStateDriver.lua:72: in function <Interface\FrameXML\SecureStateDriver.lua:62>:
Interface\FrameXML\SecureStateDriver.lua:109: in function <Interface\FrameXML\SecureStateDriver.lua:79>:
 
10-17-08, 12:52 PM   #114
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
tables are 1-index in lua, not 0.
 
10-17-08, 03:22 PM   #115
Bruners
A Flamescale Wyrmkin
 
Bruners's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 125
Complete solution is as follows
Code:
if unit=="target" and playerClass == "ROGUE" or playerClass == "DRUID" then
	local cparr = {}
		for i = 1, 5 do
			cparr[i] = pp:CreateTexture(nil, "OVERLAY")
			cparr[i]:SetTexture"Interface\\AddOns\\oUF_Brun\\textures\\combo"
			cparr[i]:SetWidth(16)
			cparr[i]:SetHeight(16)
				if(i == 1) then
					cparr[i]:SetPoint("RIGHT", pp, "RIGHT")
				else
					cparr[i]:SetPoint("RIGHT", cparr[i-1], "LEFT")
				end
		end
	self.CPoints = cparr
	self.CPoints.unit = 'player'
end
thanks Amnith

Last edited by Bruners : 10-17-08 at 03:32 PM.
 
10-18-08, 02:26 AM   #116
Arvak
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 4
Is it possible to setup a click event on the aura buttons to, for example, allow right-clicking on an icon to remove that aura? Can it be done through the PostCreateAuraIcon hook? Would I have to refresh that binding in the PostUpdateAuraIcon block (i.e. how would the name of the button's aura be accessible)?
 
10-18-08, 02:49 AM   #117
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Arvak View Post
Is it possible to setup a click event on the aura buttons to, for example, allow right-clicking on an icon to remove that aura? Can it be done through the PostCreateAuraIcon hook? Would I have to refresh that binding in the PostUpdateAuraIcon block (i.e. how would the name of the button's aura be accessible)?
This is what i use, it works exept when you try to cancel kharazan chess event buff.

Code:
	button:SetScript('OnMouseUp', function(self, mouseButton)
		if mouseButton == 'RightButton' then
			CancelUnitBuff('player', index)
		end
	end)
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
 
10-18-08, 04:15 AM   #118
Arvak
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 4
Originally Posted by Caellian View Post
This is what i use, it works exept when you try to cancel kharazan chess event buff.

Code:
	button:SetScript('OnMouseUp', function(self, mouseButton)
		if mouseButton == 'RightButton' then
			CancelUnitBuff('player', index)
		end
	end)
That's exactly what I need. Thank you. (Edit: added a check for (not debuff) on top of this so that fat-fingering stuff like "weakened soul" doesn't take off something nearby like flask).

It's interesting that it fails to remove chess aura. Maybe someone else knows more about this?

Last edited by Arvak : 10-18-08 at 04:26 AM.
 
10-18-08, 06:03 AM   #119
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Arvak View Post
That's exactly what I need. Thank you. (Edit: added a check for (not debuff) on top of this so that fat-fingering stuff like "weakened soul" doesn't take off something nearby like flask).

It's interesting that it fails to remove chess aura. Maybe someone else knows more about this?
The chess aura is not a player created buff
 
10-18-08, 06:49 AM   #120
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
How would you add a failsafe so it doesn't generate an error when someone is trying ?
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF - Layout discussion


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