Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-13-13, 06:13 PM   #1
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Issue with UnitBuff

Right so, this is a tiny addon i've had for a while to auto answer ready checks depnding on the situation.

Everything works exept the flask part, flask is always nil and i don't understand what i did wrong.

Code:
local _, caelUI = ...

caelUI.readycheck = caelUI.createModule("ReadyCheck")

local GetSpellName = function(spellId)
	return GetSpellInfo(spellId)
end

local flasks = {
	-- Cataclysm
	GetSpellName(80719),		-- Flask of Steelskin
	GetSpellName(80720),		-- Flask of the Draconic Mind
	GetSpellName(80721),		-- Flask of the Winds
	GetSpellName(80723),		-- Flask of Titanic Strength
	GetSpellName(94162),		-- Flask of Flowing Water

	-- Pandaria
	GetSpellName(105694),	-- Flask of the Earth
	GetSpellName(105691),	-- Flask of the Warm Sun
	GetSpellName(105696),	-- Flask of Winter's Bite
	GetSpellName(105693),	-- Flask of Falling Leaves
	GetSpellInfo(105689),	-- Flask of Spring Blossoms
}

ReadyCheckListenerFrame:SetScript("OnShow", nil)

local isGuildGroup

caelUI.readycheck:SetScript("OnEvent", function(self, event)
	if event == "PLAYER_ENTERING_WORLD" then
		hooksecurefunc(GuildInstanceDifficulty, "Show", function()
			isGuildGroup = true
		end)

		hooksecurefunc(GuildInstanceDifficulty, "Hide", function()
			isGuildGroup = false
		end)
	elseif event == "READY_CHECK" then
		PlaySoundFile([[Sound\Interface\ReadyCheck.wav]], "Master")

		local food = UnitBuff("player", GetSpellName(104280))

		for k, v in pairs(flasks) do
			local flask =  UnitBuff("player", k)
		end

		if (not isGuildGroup and food) or (isGuildGroup and flask and food) then
			ReadyCheckFrame:Hide()
			ConfirmReadyCheck(1)
		end
	end
end)

for _, event in next, {
	"PLAYER_ENTERING_WORLD",
	"READY_CHECK",
} do
	caelUI.readycheck:RegisterEvent(event)
end
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Issue with UnitBuff


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