Thread Tools Display Modes
06-09-11, 01:10 PM   #1
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Help with non working unit check

I don't really know how to explain this, but I am trying to fix an addon that allows either all units or a specified list of units. The all units part is working fine however when specific units are selected nothing is output to the game. There is no error it just does nothing.

From the addon

Code:
local function UnitisAllowed(unit)
	for key, val in pairs(addon.CONFIG.units) do
		if UnitIsUnit(unit, val) then return true end
	end
	return false
end
Code:
if eventType == "SPELL_AURA_APPLIED" and addon.BUFF_SPELLS[spellname] and isEnemy(destFlags) and (addon.CONFIG.allunits or UnitisAllowed(destName)) then
from the config

Code:
addon.CONFIG = {
	allunits = false, 
	units = {
		"target",
		"focus",
	},
}
Am I using the correct syntax for the check? I'm just not sure why it is failing.
  Reply With Quote
06-11-11, 09:43 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
What immediately strikes me is that you're using destName in the UnitIsUnit check. I don't think that'll work unless dest is a group member.

You could try doing UnitisAllowed(destGUID)) instead, and then doing something like this instead:
Code:
local function UnitisAllowed(guid)
	for key, val in pairs(addon.CONFIG.units) do
		if UnitGUID(val) == guid then return true end
	end
	return false
end
__________________
Grab your sword and fight the Horde!
  Reply With Quote
06-12-11, 07:09 AM   #3
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Thanks, I had actually already changed UnitisAllowed(destGUID) after reading through some of the wowprogramming.com documents. I'll try it out and see if it works. Thank you again.
  Reply With Quote
06-15-11, 03:26 PM   #4
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Sadly I still haven't been able to get this working. If anyone has any ideas they would be greatly appreciated.
  Reply With Quote
06-15-11, 07:50 PM   #5
Xinhuan
A Chromatic Dragonspawn
 
Xinhuan's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 174
UnitIsUnit only works on UnitIDs. Like UnitIsUnit("target", "focustarget"). Using guids will not work and using player names will only work if they are in your party or raid.

You should just compare their GUIDs directly instead (string compare).
__________________
Author of Postal, Omen3, GemHelper, BankItems, WoWEquip, GatherMate, GatherMate2, Routes and Cartographer_Routes
  Reply With Quote
06-16-11, 02:39 PM   #6
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
I'm sorry if these are dumb questions, I'm really trying. I'm not overly familiar with lua or any other programming language for that matter and I think I may be in over my head here.

Following (I hope) your advise I've gone to

Code:
local function UnitisAllowed(unit)
	if not addon.CONFIG.allunits then
		if UnitID == "target" or UnitID == "focus" or UnitID == "mouseover" then return true end
	end
	else
	return false
end
Code:
if eventType == "SPELL_AURA_APPLIED" and addon.BUFF_SPELLS[spellname] and isEnemy(destFlags) and (addon.CONFIG.allunits or UnitisAllowed(destID)) then
???
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with non working unit check


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