WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   UnitGroupRolesAssigned evaluation and code help (https://www.wowinterface.com/forums/showthread.php?t=29535)

Manaman 12-24-09 08:54 AM

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.

Soeters 12-24-09 09:24 AM

You're using
Code:

AM_Role = UnitGroupRolesAssigned(player)
Which should be
Code:

AM_Role = UnitGroupRolesAssigned("player")

Akryn 12-24-09 01:06 PM

Quote:

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.

Manaman 12-25-09 12:46 AM

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.

Akryn 12-25-09 01:02 AM

Quote:

Originally Posted by Manaman (Post 171851)
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.

Manaman 12-25-09 01:23 AM

Thank you for all the assistance.


All times are GMT -6. The time now is 09:41 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI