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:
local unitTag = GetGroupUnitTagByIndex(index)
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:
function LGRI.UpdateMyRole(eventId, unitTag)
if unitTag ~= nil then
local index = GetGroupIndexByUnitTag("player")
local myUnitTag = GetGroupUnitTagByIndex(index)
if unitTag ~= myUnitTag then return end
end
local my = LGRI.my
local roleId = GetGroupMemberSelectedRole("player")
-- Role
if roleId == 1 then
my.roleIcon = "esoui/art/lfg/lfg_icon_dps.dds"
LGRI.UI.MyRoleIcon:SetTexture(my.roleIcon)
elseif roleId == 2 then
my.roleIcon = "esoui/art/lfg/lfg_icon_tank.dds"
LGRI.UI.MyRoleIcon:SetTexture(my.roleIcon)
elseif roleId == 4 then
my.roleIcon = "esoui/art/lfg/lfg_icon_healer.dds"
LGRI.UI.MyRoleIcon:SetTexture(my.roleIcon)
else
my.roleIcon = "esoui/art/armory/builditem_icon.dds"
LGRI.UI.MyRoleIcon:SetTexture(my.roleIcon)
end
end
function LGRI.OnAddOnLoaded(event, addonName)
if addonName ~= LGRI.name then return end
EM:UnregisterForEvent(LGRI.name, EVENT_ADD_ON_LOADED)
LargeGroupRoleIcons.Initialize()
EM:RegisterForEvent(LGRI.name .. "MyRoleChanged", EVENT_GROUP_MEMBER_ROLE_CHANGED, LGRI.UpdateMyRole)
--EM:AddFilterForEvent(EVENT_GROUP_MEMBER_ROLE_CHANGED, REGISTER_FILTER_UNIT_TAG, "player")
--EM:AddFilterForEvent(LGRI.name .. "MyRoleChanged", EVENT_GROUP_MEMBER_ROLE_CHANGED, REGISTER_FILTER_UNIT_TAG,
EM:RegisterForEvent(LGRI.name .. "ILeftGroup", EVENT_GROUP_MEMBER_LEFT,
function(eventId, memberCharacterName, groupLeaveReason , isLocalPlayer, isLeader, memberDisplayName, actionRequiredVote)
if not isLocalPlayer then return end
LGRI.UpdateMyRole()
end)
end