View Single Post
12/15/22, 07:56 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,027
One hint to your code Masteroshi:

Could work but is a manual concatenation which should not be used if there are better ways provided by ZOs:
local tag = "group"..tostring(i)

You also would not (or at least should not) always just use 1, instead of the correct constant BAG_BAGPACK for the inventory's bagId.
-> The constants and API functions exist to make it compatible, also for future use cases. So better make use of them instead of re-inventing your own code that maybe works today, but breaks tomorrow.


Definately works (and is API and should be used here):
Code:
local unitTag = GetGroupUnitTagByIndex(i)
Attention:
A unitTag may be nil if there are gaps in the group indices! So GetGroupUnitTagByIndex(index) might return nil, add a nil check afterwards!
Code:
local unitTag = GetGroupUnitTagByIndex(i)
if unitTag ~= nil and DoesUnitExist(unitTag) then
 --Only here we know the unit at index i exists!
end

Last edited by Baertram : 07/03/23 at 07:39 AM.
  Reply With Quote