Thread Tools Display Modes
09-19-15, 06:06 AM   #1
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Addon help

So here's a tiny module i recently added in my UI. Basically what it does amongst other things is, whenever i target one of those new rares in Tanaan jungle, it lists a custom group and when the rare is dead, it disbands the raid.

It's working just fine exept that, every time it disbands the raid, it also throws an error and i don't understand why. I even added a 5 seconds delay thinking it was doing it too fast after PLAYER_REGEN_ENABLED but that didn't help.

Anyway, here's the code and the error below it:

Code:
caelUI.rares:SetScript("OnEvent", function(self, event, addon, arg)
	if event == "CHAT_MSG_MONSTER_YELL" and (arg == "Frogan" or arg == "Tyrant Velhari" or arg == "Shadow-Lord Iskar" or arg == "Siegemaster Mar\'tak") and not IsInRaid() then
		self:RegisterEvent("PLAYER_TARGET_CHANGED")
	end

	if event == "PLAYER_TARGET_CHANGED" then
		if UnitName("target") == "Terrorfist" or UnitName("target") == "Vengeance" or UnitName("target") == "Deathtalon" or UnitName("target") == "Doomroller" then

			self:RegisterEvent("PLAYER_REGEN_ENABLED")
			self:UnregisterEvent("PLAYER_TARGET_CHANGED")
--			C_LFGList.CreateListing(Category ID, "groupName", itemLevel, "voiceChat", "comment", autoAccept)
			C_LFGList.CreateListing(16, UnitName("target"), 685, " ", "Join quick !", true)

			C_Timer.After(5, function()
				if not IsInRaid() then
					print("Converting to raid")
					ConvertToRaid()
				end
			end)

			C_Timer.After(120, function()
				print("Delisting group")
				C_LFGList.RemoveListing()
			end)
		end
	end

	if event == "PLAYER_REGEN_ENABLED" then
		C_Timer.After(5, function()
			if IsInRaid() then
				SendChatMessage("Target is dead, disbanding raid.", "RAID")
				for i = 1, GetNumGroupMembers() do
					local name, _, _, _, _, _, _, online = GetRaidRosterInfo(i)
					if online and name ~= caelUI.playerName then
						UninviteUnit(name)
					end
				end
			else
				SendChatMessage("Target is dead, disbanding group.", "PARTY")
				for i = MAX_PARTY_MEMBERS, 1, -1 do
					if GetPartyMember(i) then
						UninviteUnit(UnitName("party"..i))
					end
				end
			end
			LeaveParty()
			self:UnregisterEvent("PLAYER_REGEN_ENABLED")
		end)
	end
end)

Code:
ID: 1
Error occured in: Unnamed
Message:
caelUI attempted to call a protected function (UninviteUnit()) which may require interaction.
Debug:
   [C]: UninviteUnit()
   ...erface\AddOns\caelUI\modules\announcements\rares.lua:77:
      ...erface\AddOns\caelUI\modules\announcements\rares.lua:71
locals:
nil
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
09-19-15, 08:38 AM   #2
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
This function is protected, and may only be called in response to hardware event.
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill
  Reply With Quote
09-19-15, 09:05 AM   #3
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
Originally Posted by Banknorris View Post
This function is protected, and may only be called in response to hardware event.
That i could gather from the error yeah, but it still works so i'm confused.

Also, while i'm at it, how could i improve the whole PLAYER_REGEN_ENABLED part, i'm playing mainly a hunter and if i feign death, i go out of combat so it triggers that part of the code when it shouldn't have.
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }

Last edited by Caellian : 09-19-15 at 09:20 AM.
  Reply With Quote
09-19-15, 11:07 AM   #4
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
Originally Posted by Caellian View Post
Also, while i'm at it, how could i improve the whole PLAYER_REGEN_ENABLED part, i'm playing mainly a hunter and if i feign death, i go out of combat so it triggers that part of the code when it shouldn't have.
Lua Code:
  1. local isFeignDeath = UnitAura("player", "Feign Death") ~= nil

Confirm that you're not feigning death or keep checking until you no longer are (C_Timer.NewTicker) before proceeding with your delayed function.
  Reply With Quote
09-19-15, 11:12 AM   #5
Caellian
A Frostmaul Preserver
 
Caellian's Avatar
Join Date: May 2006
Posts: 281
One more question, is it possible to check from within an addon if i have already looted the rare ? I was thinking to use that as a trigger to disband/leave group.
__________________
if (sizeof(workload) > sizeof(brain_capacity)) { die('System Overload'); }
  Reply With Quote
09-19-15, 12:04 PM   #6
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
Looting a rare should be marked by Blizzard completing a specific quest for each rare. This type of quest is just a marker quest and does not show up in a quest list. However, when using Blizzard APIs to determine if a quest is complete it will work with these marker quests. Therefore, you would want for each rare to know the associated Blizzard marker quest and use the API with that value to see whether the person has looted that rare.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Addon help

Thread Tools
Display Modes

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