Thread Tools Display Modes
06-15-10, 05:18 AM   #1
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
Two oUF questions.

Hello, I have two questions regarding oUF.

First one; I'm trying to colour my castbar icon border depending on whether or not the cast is interruptable. Red when it isn't, black when it is.

Here's the code:

Code:
			local bg = CreateFrame ("Frame", nil, iconFrame)
				bg:SetBackdrop( { 
				bgFile = "Interface\\ChatFrame\\ChatFrameBackground", 
			})


			local function castGlow(self, event, unit, interrupt)
				if(cb.NotInterruptible) then
					bg:SetBackdropColor(1, 0, 0)
				else
					bg:SetBackdropColor(0, 0, 0)
				end
			end

			self.PostCastStart = castGlow
			self.PostChannelStart = castGlow
I've tried a lot of variations on this, but no success. Mostly it's black, but sometimes it even turns white.

When I inverse the 'if not interruptible' function, it'll always be red.

--

Second one:

I regularly get an unpack error when oUF is trying to unpack the power colours, but can't find them somehow. For example, when I dismiss a vehicle, this error will pop up. It happens on other random events as well.

Code:
Interface\AddOns\oUF\elements\power.lua:22: bad argument #1 to 'unpack' (table expected, got nil)
Here's the relevant part in the lua file:

Code:
local Update = function(self, event, unit)

	if(self.unit ~= unit) then return end

	local _, UnitPowerType = UnitPowerType(unit)
	local pr, pg, pb = unpack(powercolors[UnitPowerType or "MANA"])
I use the colour in the following part:

Code:
	if(bar) then
			bar:SetStatusBarColor(pr, pg, pb)
		end
I've tried adding a check to it by changing it to this:

Code:
	if(bar) then
		if(self.Power) then
			bar:SetStatusBarColor(pr, pg, pb)
		else
			bar:SetStatusBarColor(1, 1, 0) -- just testing to see if this fixes a bug
		end
	end
But it doesn't help.

--

I'd greatly appreciate help with these two problems.
  Reply With Quote
06-15-10, 07:12 AM   #2
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
for the first part you need to say which version of oUF you are using. This site hosts version 1.3.xx, but there is a development version on GitHub that contains significant changes to the castbar module.



For the second part, Blizzard use some odd power types in vehicles (STEAM and PYRITE, for example) that never get assigned colours in the standard table.

You can either manually assign colours to these power types,

or slightly change your logic to provide a fall back colour when the current power type does not exist in the table:
Code:
local Update = function(self, event, unit)

	if(self.unit ~= unit) then return end

	local _, UnitPowerType = UnitPowerType(unit)
	local pr, pg, pb = unpack(powercolors[UnitPowerType or "MANA"])
to
Code:
local Update = function(self, event, unit)

	if(self.unit ~= unit) then return end

	local _, UnitPowerType = UnitPowerType(unit)
	local pr, pg, pb = unpack(powercolors[UnitPowerType] or powercolors["MANA"])
  Reply With Quote
06-15-10, 07:57 AM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
The fuels in vehicles use "AMMOSLOT" and "FUEL" in the default color table. Others are not specified.

http://wowprogramming.com/utils/xmlb.../UnitFrame.lua

If your want to make the shield appear. Using sth. like this will work in oUF 1.3.28

Code:
local function checkShield(self, event, unit, interrupt)
  if interrupt then
    --show shield
  else
    --no shield
  end
end

local function checkCast(event, unit, name, rank, text, castid, interrupt)
  checkShield(self, event, unit, interrupt)
end

local function checkChannel(event, unit, name, rank, text, interrupt)
  checkShield(self, event, unit, interrupt)
end

self.PostCastStart = checkCast
self.PostChannelStart = checkChannel
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
06-15-10, 08:19 AM   #4
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
Originally Posted by zork View Post
The fuels in vehicles use "AMMOSLOT" and "FUEL" in the default color table. Others are not specified.

http://wowprogramming.com/utils/xmlb.../UnitFrame.lua
Not quite true.

When getting the UnitPowerType I have seen return values of POWER_TYPE_PYRITE and POWER_TYPE_STEAM which are not included in the standard table. So Indexing by this value *can* be problematic.

There are also POWER_TYPE_OOZE, POWER_TYPE_HEAT and POWER_TYPE_BLOOD_POWER.
  Reply With Quote
06-15-10, 08:37 AM   #5
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Why are you editing oUF\elements\power.lua?
__________________
「貴方は1人じゃないよ」
  Reply With Quote
06-15-10, 11:13 AM   #6
Haleth
This Space For Rent
 
Haleth's Avatar
Featured
Join Date: Sep 2008
Posts: 1,173
yj589794; that seems to work, at least with the test I use most often (Crashin' Trashin' Racing Controller ). I'll see if it completely gets rid of the error no matter what but it probably does. Thanks.

zork; looks like it's working, thanks.

haste: I'm using one of Alza's modified oUFs as the base of my UI. I edited small things to make it suit the new look.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Two oUF questions.


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