Thread Tools Display Modes
09-29-10, 10:12 PM   #1
Toragon
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jan 2009
Posts: 11
ouf UnitHealth("unit") error

Can some please help me cannot figure out why i am get this error.

This error I am getting

Code:
684x oUF-1.4.3\elements\health.lua:78: Usage: UnitHealth("unit")
oUF-1.4.3\elements\health.lua:78: in function <oUF\elements\health.lua:76>

Locals:
self = <unnamed> {
 0 = <userdata>
 ForceUpdate = <function> @ oUF\elements\health.lua:69:
 frequentUpdates = true
 PostUpdate = <function> @ oUF_AMF\common.lua:67:
 value = <unnamed> {}
 __owner = oUF_PartyUnitButton4Pet {}
 bg = <unnamed> {}
 colorClass = true
}
UnitHealth = <function> defined =[C]:-1
Path = <function> @ oUF\elements\health.lua:65:
my xml
Code:
<Ui xmlns='http://www.blizzard.com/wow/ui/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.blizzard.com/wow/ui/
..\..\FrameXML\UI.xsd'>
	<Button name='oUF_MT' inherits='SecureUnitButtonTemplate' hidden='true' virtual='true'>
		<Frames>
			<Button name='$parentTarget' inherits='SecureUnitButtonTemplate'>
				<Size>
					<AbsDimension x='100' y='25'/>
				</Size>
				<Anchors>
					<Anchor point='TOPLEFT' relativePoint='TOPRIGHT' relativeTo='$parent'>
						<Offset>
							<AbsDimension x='4' y='0'/>
						</Offset>
					</Anchor>
				</Anchors>
				<Attributes>
					<Attribute name='unitsuffix' type='string' value='target'/>
					<Attribute name='useparent-unit' type='boolean' value='true'/>
					<Attribute name='type1' type='string' value='target'/>
					<Attribute name='initial-unitWatch' type='boolean' value='true'/>
				</Attributes>
			</Button>
		</Frames>
	</Button>
	
	<Button name="oUF_PARTY" inherits="SecureUnitButtonTemplate" hidden="true" virtual="true">
		<Frames>
			<Button name="$parentPet" inherits="SecureUnitButtonTemplate">
				<Anchors>
					<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMLEFT" relativeTo="$parent">
						<Offset>
							<AbsDimension x="-8" y="0"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Attributes>
					<Attribute name="unitsuffix" type="string" value="pet"/>
					<Attribute name="useparent-unit" type="boolean" value="true"/>
					<Attribute name="type1" type="string" value="target"/>
					<Attribute name="initial-unitWatch" type="boolean" value="true"/>
				</Attributes>
			</Button>
		</Frames>
	</Button>
	
	<Script file='config.lua'/>
	<Script file='AMF_Tags.lua'/>
	<Script file='common.lua'/>
	<Script file='oUF_AMF.lua'/>
	<Script file='oUF_AMFMT.lua'/>
	<Script file='oUF_AMFPARTY.lua'/>

</Ui>
Code:
local _, ns = ...
local config = ns.config
local colors = oUF.colors

-- menu function
local shortVal
do
	local format = string.format

	function shortVal(value)
		local returnValue = ''

		if value > 1e6 then
			returnValue = format('%dm', value / 1e6)
		elseif value > 1e3 then
			returnValue = format('%dk', value / 1e3)
		else
			returnValue = format('%d', value)
		end

		return returnValue
	end
end

local function updateThreatStatus(self, event, u)
	if (self.unit ~= u) then return end
	local s = UnitThreatSituation(u)
	if s and s > 1 then
		local r, g, b = GetThreatStatusColor(s)
		self:SetBackdropColor(r, g, b, 1)
	--	self:SetBackdropBorderColor(r, g, b, 1)
	else
		self:SetBackdropColor(0, 0, 0, 1)
	--	self:SetBackdropBorderColor(.0, .3, 0, 1)
	end
end

local addMenu
do
	local format = string.format
	local gsub = string.gsub
	local upper = string.upper

	local function SpawnMenu(self)
		local dropdown = _G[format('%sFrameDropDown', gsub(self.unit, '(.)', upper, 1))]

		if dropdown then
			ToggleDropDownMenu(1, nil, dropdown, 'cursor')
		elseif (self.unit:match('party')) then
			ToggleDropDownMenu(1, nil, _G[format('PartyMemberFrame%dDropDown', self.id)], 'cursor')
		else
			FriendsDropDown.unit = self.unit
			FriendsDropDown.id = self.id
			FriendsDropDown.initialize = RaidFrameDropDown_Initialize
			ToggleDropDownMenu(1, nil, FriendsDropDown, 'cursor')
		end
	end

	function addMenu(self)
		self.menu = SpawnMenu
		self:RegisterForClicks('anyup')
		self:SetAttribute('type2', 'menu')
	end
end

ns.addMenu = addMenu
local PostUpdateHealth = function(Health, unit, min, max)
	
	
	if(UnitIsDead(unit)) then
		Health:SetValue(0)
		Health.value:SetText"RIP"			
	elseif(UnitIsGhost(unit)) then
		Health:SetValue(0)
		Health.value:SetText"GHO"			
	elseif(not UnitIsConnected(unit)) then	
		Health.value:SetText"OFF"	
	elseif(c == 'worldboss') then
		Health.value:SetText(shortVal(min).."  "..(round(min/max, 2)*100))	
	else
		Health.value:SetText(shortVal(min))		
	end
end

-- post update power function
local function PostUpdatePower(Power, unit, min, max)

	
	if(not UnitIsConnected(unit)) then
		Power.value:SetText()
		Power:SetValue(0)
	elseif(UnitIsDead(unit) or UnitIsGhost(unit)) then
		Power:SetValue(0)
		Power.value:SetText()
	else
		Power.value:SetText(shortVal(min))
	end
	
	-- color power text by power type
	local _, ptype = UnitPowerType(unit)
        if(colors.power[ptype]) then
            r, g, b = unpack(colors.power[ptype])
	end

	Power.value:SetTextColor(r, g, b)

end


-- health bar function
local function addHealthBar(self)
	local health = CreateFrame('StatusBar', nil, self)
	health:SetPoint('TOPRIGHT', self, 'TOPRIGHT', 0, -1)
	health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, -1)
	health:SetStatusBarTexture(config.TEXTURE)
	health:SetHeight(config.HEALTHHEIGHT)
	health.PostUpdate = PostUpdateHealth
	health.colorClass = true
	health.frequentUpdates = true

	local healthBG = health:CreateTexture(nil, 'BORDER')
	healthBG:SetAllPoints(health)
	healthBG:SetTexture(1 / 3, 1 / 3, 1 / 3)
	health.bg = healthBG
		
	
	health.value = health:CreateFontString(nil, "OVERLAY")
	health.value:SetFont(config.FONT, config.FONTSIZE, "OUTLINE")
	health.value:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -4, -8)	
	health.value:SetTextColor(0,1,0)
	self.Health = health
	


end
ns.addHealthBar = addHealthBar


function addPowerBar(self)
	local power = CreateFrame('StatusBar', nil, self)
	power:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, 8)
	power:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 0, 8)
	power:SetPoint('TOP', self.Health, 'BOTTOM', 0, -2)
	power:SetStatusBarTexture(config.TEXTURE)
	power:SetHeight(config.POWERHEIGHT)

	power.colorTapping = true
	power.colorDisconnected = true
	power.colorPower = true
	power.colorReaction = true

	power.PostUpdate = PostUpdatePower

	local powerBG = power:CreateTexture(nil, 'BORDER')
	powerBG:SetAllPoints(power)
	powerBG:SetTexture(1 / 3, 1 / 3, 1 / 3)
	power.bg = powerBG
	
	power.value = power:CreateFontString(nil, "OVERLAY")
	power.value:SetFont(config.FONT, config.FONTSIZE, "OUTLINE")
	power.value:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 4, -8)	
	power.value:SetTextColor(0,1,0)

	self.Power = power
end
ns.addPowerBar = addPowerBar

local function addName(self)
	
	self.Name = self:CreateFontString(nil, "OVERLAY")
	self.Name:SetFont(config.FONT, config.FONTSIZE, "OUTLINE")
	self:Tag(self.Name, '[difficulty][classification] [afkdnd][raidcolor][abbrevname]')
	self.Name:SetPoint("BOTTOM", self, "BOTTOM", 0, -8)	

end
ns.addName = addName

local function addThreat(self)

	self:RegisterEvent("UNIT_THREAT_LIST_UPDATE", updateThreatStatus)
	self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", updateThreatStatus)

end
ns.addThreat = addThreat


-- raid icon function
local function addRaidIcon(self)
	local raidicon = self.Health:CreateTexture(nil, 'OVERLAY')
	raidicon:SetPoint('TOP', self, 'TOP', 0, 8)
	raidicon:SetSize(16, 16)

	self.RaidIcon = raidicon
end
ns.addRaidIcon = addRaidIcon

-- DebuffHighlight function
local function addDebuffHighlightBackdrop(self)
	local debuffBackdrop = {
		Alpha = 1,
		Filter = false,
	}

	self.DebuffBackdrop = debuffBackdrop
end
ns.addDebuffHighlightBackdrop = addDebuffHighlightBackdrop

-- Healcomm bar function
local function addHealCommBars(self, allowOverflow)
	local healcommbar = CreateFrame('StatusBar', nil, self.Health)
	healcommbar:SetStatusBarTexture(config.TEXTURE)
	healcommbar:SetStatusBarColor(0, 1, 0, 0.25)
	healcommbar:SetPoint('LEFT', self.Health, 'LEFT', 0, 0)
	self.allowHealCommOverflow = allowOverflow

	self.HealCommBar = healcommbar
end
ns.addHealCommBars = addHealCommBars

-- Range function
local function addRange(self)
	local range = {
		insideAlpha = 1,
		outsideAlpha = 2 / 3,
	}
	self.Range = range
end
	ns.addRange = addRange
local _, ns = ...
local config = ns.config
local colors = oUF.colors

local Style
do
local addHealthBar = ns.addHealthBar
local addPowerBar = ns.addPowerBar
local addRaidIcon = ns.addRaidIcon
local addMenu = ns.addMenu
local addName = ns.addName


function Style(self, unit)

print(self)
-- Shared layout code.
self:RegisterForClicks('AnyUp')
self:SetScript('OnEnter', UnitFrame_OnEnter)
self:SetScript('OnLeave', UnitFrame_OnLeave)

addMenu(self)

self:SetBackdrop(config.BACKDROP)
self:SetBackdropColor(0, 0, 0)

self:SetAttribute('initial-scale', .7)
self:SetAttribute('initial-height', config.UNITHEIGHT)
self:SetAttribute('initial-width', config.UNITWIDTH)

addHealthBar(self)
addPowerBar(self)
addName(self)



self.disallowVehicleSwap = true



end


oUF:RegisterStyle('oUF_AMFPARTY', Style)


oUF:Factory(function(self)

self:SetActiveStyle('oUF_AMFPARTY')
local party = self:SpawnHeader('oUF_Party', nil, 'party,raid',
--'showParty', true,
'showParty', true,
'template', 'oUF_PARTY',
'yOffset', -20)
party:SetPoint("CENTER", UIParent, "CENTER", -450, -150)
end)
  Reply With Quote
09-30-10, 12:59 AM   #2
Taroven
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 49
Would be helpful to know which version of oUF you use. You may also want to post this to the oUF forum instead of Lua/XML Help.

UnitHealth is being passed something it doesn't like, probably nil. In the stack you posted, it seems to originate from a partypet frame. Try disabling those.
__________________
Former author of EventHorizon Continued and Other Releases.
  Reply With Quote
09-30-10, 07:16 AM   #3
Toragon
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jan 2009
Posts: 11
I am use oUF 1.4 and I am testing on the ptr. Yes it is the party pets health that getting a nil value. I cannot figure out how to fix it so I can show them.
  Reply With Quote
09-30-10, 09:26 AM   #4
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
The PTR contains many of the API changes that will appear in Cataclysm.
As such it is best to use the version of oUF on Haste's GitHub when testing on the Beta or PTR servers.
  Reply With Quote
09-30-10, 02:15 PM   #5
Toragon
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jan 2009
Posts: 11
That is the one I am using the one off git.
  Reply With Quote
09-30-10, 04:05 PM   #6
Toragon
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jan 2009
Posts: 11
I have re-posted this in the oUF forums. Thanks
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » ouf UnitHealth("unit") error


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