View Single Post
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