Thread Tools Display Modes
12-24-09, 08:54 AM   #1
Manaman
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 39
UnitGroupRolesAssigned evaluation and code help

Been trying to modify Adam's Mark's code to function only under 3 circumstances: Assigned as Tank role by the LFD tool; Assigned as Main Tank in raid; or Assigned as Main Assist in raid. The part I am testing currently, and having trouble with is the Tank Role assignment.

Code:
AM_IsEnabled = true;
AM_UnitPlayerFaction = UnitFactionGroup("player");
AM_AssignedRaidSymbol = 8;
AM_ZoneReminderEnabled = true;
AM_Role = UnitGroupRolesAssigned(player);

if (AM_Role == "isTank") then
	AM_Tank = true
end

if(AM_UnitPlayerFaction == "Alliance") then
	AM_OppositePlayerFaction = "Horde";
elseif(AM_UnitPlayerFaction == "Horde") then
	AM_OppositePlayerFaction = "Alliance";
end

function AM_SlashCommand(cmd, arg2)
	if(cmd == "settings") then AM_OptionsFrame:Show(); end
	if(cmd == "on" or cmd == "enable")     then SetEnable(true); end
	if(cmd == "off" or cmd == "disable")    then SetEnable(false); end
	if(cmd == "symbol") then DEFAULT_CHAT_FRAME:AddMessage(arg2); end
end

SLASH_AUTOMARK1 = "/am";
SLASH_AUTOMARK2 = "/automark";
SlashCmdList["AUTOMARK"] = AM_SlashCommand;

function MarkTarget(markID)
	if(UnitHealth("target") > 0) then
		if(GetRaidTargetIndex("target") == nil or GetRaidTargetIndex("target") < AM_AssignedRaidSymbol) then
			if((GetPartyAssignment("MAINTANK", "player") or GetPartyAssignment("MAINASSIST", "player") or AM_Tank) and GetRaidTargetIndex("target") ~= markID and UnitFactionGroup("target") ~= AM_OppositePlayerFaction ~= AM_UnitPlayerFaction) then
				SetRaidTargetIcon("target", markID);
			end
		end
	end
end



function SetAssignedRaidSymbol(ID)
	AM_AssignedRaidSymbol = ID;
	if(ID == 8) then
		DEFAULT_CHAT_FRAME:AddMessage("Your Assigned Raid Symbol is: Skull");
	elseif(ID == 7) then
		DEFAULT_CHAT_FRAME:AddMessage("Your Assigned Raid Symbol is: Cross");
	elseif(ID == 6) then
		DEFAULT_CHAT_FRAME:AddMessage("Your Assigned Raid Symbol is: Square");
	elseif(ID == 5) then
		DEFAULT_CHAT_FRAME:AddMessage("Your Assigned Raid Symbol is: Moon");
	elseif(ID == 4) then
		DEFAULT_CHAT_FRAME:AddMessage("Your Assigned Raid Symbol is: Triangle");
	elseif(ID == 3) then
		DEFAULT_CHAT_FRAME:AddMessage("Your Assigned Raid Symbol is: Diamond");
	elseif(ID == 2) then
		DEFAULT_CHAT_FRAME:AddMessage("Your Assigned Raid Symbol is: Circle");
	elseif(ID == 1) then
		DEFAULT_CHAT_FRAME:AddMessage("Your Assigned Raid Symbol is: Star");
	end
end

function SetEnable(status)
	AM_IsEnabled = status;
	if(status ~= true) then
		DEFAULT_CHAT_FRAME:AddMessage("Marking Disabled.");
	else
		DEFAULT_CHAT_FRAME:AddMessage("Marking Enabled.");
	end
end

function SetZoneinEnable(status)
	AM_ZoneReminderEnabled = status;
	if(status ~= true) then
		DEFAULT_CHAT_FRAME:AddMessage("Zone-In Reminder Disabled.");
	else
		DEFAULT_CHAT_FRAME:AddMessage("Zone-In Reminder Enabled.");
	end
end
I am very new to lua coding. I have mostly just modified a few lines here or there to suit my needs. I am having trouble figuring out how to properly evaluate the UnitGroupRolesAssigned to a true for when my player is assigned the Tank role. Anyone have any advice? Thanks.
  Reply With Quote
12-24-09, 09:24 AM   #2
Soeters
A Warpwood Thunder Caller
 
Soeters's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 97
You're using
Code:
AM_Role = UnitGroupRolesAssigned(player)
Which should be
Code:
AM_Role = UnitGroupRolesAssigned("player")
__________________
  Reply With Quote
12-24-09, 01:06 PM   #3
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Code:
AM_Role = UnitGroupRolesAssigned(player);

if (AM_Role == "isTank") then
	AM_Tank = true
end
should be

Code:
    AM_Tank = UnitGroupRolesAssigned("player")
(edit: var name)

As mentioned, the quotes are required; but also, your if statement will always be false and will sometimes error, because the first return value of UnitGroupRolesAssigned is a boolean that is true if the unit is the tank, not a string like "isRole" -- just remove it entirely as above and it should work.

Last edited by Akryn : 12-24-09 at 01:55 PM.
  Reply With Quote
12-25-09, 12:46 AM   #4
Manaman
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 39
Oh, I was going off of WOWWiki's API section: http://www.wowwiki.com/API_UnitGroupRolesAssigned, which says:

Code:
isTank, isHeal, isDPS = UnitGroupRolesAssigned(Unit);
While other API articles states ("unit"), and not as written above with (Unit). So I went with that notation of no quotations. As well, it appeared the return from that API call was in the form of either isTank = true, isHeal = true, or isDPS = true. But you say I just do:

Code:
AM_Tank = UnitGroupRolesAssigned("player")
without needing to separate out the isHeal or isDPS responses somehow? As I said above, I am new to lua. Thanks.
  Reply With Quote
12-25-09, 01:02 AM   #5
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by Manaman View Post
But you say I just do:

Code:
AM_Tank = UnitGroupRolesAssigned("player")
without needing to separate out the isHeal or isDPS responses somehow? As I said above, I am new to lua. Thanks.
Yes that's correct. As an example, you could also do:

Code:
local a, b, c = UnitGroupRolesAssigned("player")
if a == true then
    AM_Tank = true
end
The point being that UnitGroupRolesAssigned returns three boolean values, the first one is true if the player is a tank, the second one is true if the player is a healer, the third one is true if the player is DPS. The above code simplifies to:

Code:
local a, b, c = UnitGroupRolesAssigned("player")
AM_Tank = a
and then further to what I posted above.
  Reply With Quote
12-25-09, 01:23 AM   #6
Manaman
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Apr 2006
Posts: 39
Thank you for all the assistance.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » UnitGroupRolesAssigned evaluation and code 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