View Single Post
03/19/23, 03:34 PM   #16
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,009
If the unitTag is always nil, there either is a bug in that event or your parameter order of that event is wrong so that you do not actually check the unitTag but some other param which returns nil. Did you add the 1st parameter eventId in your callback?

>this returns my index
And what is your index then? if it's 4294967296 it's wrong Should be something like 1, 2, 3 etc.


You cannot use a function in the event filters!
Code:
EM:AddFilterForEvent(LGRI.name .. "MyRoleChanged", EVENT_GROUP_MEMBER_ROLE_CHANGED, REGISTER_FILTER_UNIT_TAG,
    function (unitTag)
That won't work afaik. Only fixed values are allowed.
That event filter would only work with something like this:
Code:
EM:AddFilterForEvent(LGRI.name .. "MyRoleChanged", EVENT_GROUP_MEMBER_ROLE_CHANGED, REGISTER_FILTER_UNIT_TAG, "group1")


And this would neither work or at least is not needed.
GetGroupUnitTagByIndex should always return "group" .. <number> so it cannot be anything else than group..index as you have passed in the index.

Lua Code:
  1. local unitTag = GetGroupUnitTagByIndex(index)
  2.         if not unitTag == "group"..index then return end


Your functin function LGRI.UpdateMyRole(eventId) needs the unitTag as 2nd parameter and then you can use that function properly.


Lua Code:
  1. function LGRI.UpdateMyRole(eventId, unitTag)
  2.     if unitTag ~= nil then
  3.     local index = GetGroupIndexByUnitTag("player")
  4.     local myUnitTag = GetGroupUnitTagByIndex(index)
  5.     if unitTag ~= myUnitTag then return end
  6.     end
  7.  
  8.     local my = LGRI.my
  9.     local roleId = GetGroupMemberSelectedRole("player")
  10.  
  11.     -- Role
  12.     if roleId == 1 then
  13.         my.roleIcon = "esoui/art/lfg/lfg_icon_dps.dds"
  14.         LGRI.UI.MyRoleIcon:SetTexture(my.roleIcon)
  15.  
  16.     elseif roleId == 2 then
  17.         my.roleIcon = "esoui/art/lfg/lfg_icon_tank.dds"
  18.         LGRI.UI.MyRoleIcon:SetTexture(my.roleIcon)
  19.     elseif roleId == 4 then
  20.         my.roleIcon = "esoui/art/lfg/lfg_icon_healer.dds"
  21.         LGRI.UI.MyRoleIcon:SetTexture(my.roleIcon)
  22.     else
  23.         my.roleIcon = "esoui/art/armory/builditem_icon.dds"
  24.         LGRI.UI.MyRoleIcon:SetTexture(my.roleIcon)
  25.     end
  26. end
  27.  
  28. function LGRI.OnAddOnLoaded(event, addonName)
  29.     if addonName ~= LGRI.name then return end
  30.     EM:UnregisterForEvent(LGRI.name, EVENT_ADD_ON_LOADED)
  31.  
  32.     LargeGroupRoleIcons.Initialize()
  33.  
  34.     EM:RegisterForEvent(LGRI.name .. "MyRoleChanged", EVENT_GROUP_MEMBER_ROLE_CHANGED, LGRI.UpdateMyRole)
  35.     --EM:AddFilterForEvent(EVENT_GROUP_MEMBER_ROLE_CHANGED, REGISTER_FILTER_UNIT_TAG, "player")
  36.     --EM:AddFilterForEvent(LGRI.name .. "MyRoleChanged", EVENT_GROUP_MEMBER_ROLE_CHANGED, REGISTER_FILTER_UNIT_TAG,
  37.  
  38.     EM:RegisterForEvent(LGRI.name .. "ILeftGroup", EVENT_GROUP_MEMBER_LEFT,
  39.     function(eventId, memberCharacterName, groupLeaveReason , isLocalPlayer, isLeader, memberDisplayName, actionRequiredVote)
  40.         if not isLocalPlayer then return end
  41.         LGRI.UpdateMyRole()
  42.     end)
  43. end

Last edited by Baertram : 03/19/23 at 03:53 PM.
  Reply With Quote