Quantcast Help with non working unit check - WoWInterface
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
06-27-11, 06:18 PM   #7
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Still unable to solve this. Any and all input is appreciated.
  Reply With Quote
06-27-11, 06:33 PM   #8
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,257
There's an obvious error in the last snippet of code you posted.
The function is passed a 'unit' parameter but in the code you're checking against 'UnitID'.

Apart from that, we need more code.
Which addon is it, can you post a pastey of the full code?
  Reply With Quote
06-28-11, 07:49 AM   #9
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Here is the pastey

http://pastebin.com/Ez2MTqrE

I think that code was leftover from the first bit before I started trying to fix the check. I had replaced unit with guid.
  Reply With Quote
06-28-11, 12:01 PM   #10
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 329
Combat log events don't use the general 'UnitID' like "target" and "focus" things like that. Instead it uses 'UnitGUID' which is a specific string of numbers that is unique to that unit.

What you would ultimately have to do is determine the UnitGUID of all the parameters in your table there, and attempt to match them with the combat log UnitGUID.

Something like this:

Code:
local function isallowedunit(guid)
	for key, val in pairs(ncSpellalertDB.CONFIG.units) do
		local currentID = UnitGUID(val)
		if guid == currentID then
			return true
		end
	end
	return false
end

Last edited by suicidalkatt : 06-28-11 at 12:10 PM.
  Reply With Quote
06-28-11, 12:12 PM   #11
Sauerkraut
A Wyrmkin Dreamwalker
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 52
Thank you suicidalkatt! I'll try that as soon as the servers come back up.
  Reply With Quote

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

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