WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Getting a frame through global (https://www.wowinterface.com/forums/showthread.php?t=59699)

dragonflyy 10-26-23 06:14 PM

Getting a frame through global
 
I have been away from WoW for 2 years, just started playing again and wanted to update an old addon I had made. However, I am running into a problem. I need to get each of the party frames, but the method I've used before is not working.

If I manually grab the frames:
Code:

PartyFrame.MemberFrame1
then it returns a table and I can hide/show that frame no problem.

Once I try to add it to a variable, it comes up nil. The way I've done this in the past was:
Code:

local frame = _G["PartyFrame.MemberFrame1"]
This returns nil, using just _G["PartyFrame"] does give me the PartyFrame, but I can't get the MemberFrames individually. The reason I used this method was a for loop:
Code:

for i=1, 4 do
  frame = _G["PartyFrame.MemberFrame" .. i]
end

This used to work (2 years ago) but now it's nil. Did the _G change, or am I just missing something obvious here?

Tried searching around on the internet but can't seem to find a change.

Fizzlemizz 10-26-23 09:21 PM

The .MemberFrame means it is a key of the PartyFrame ie. PartyFrame["MemberFrame1"] or _G["PartyFrame"]["MemberFrame1"]

But the (retail) member frames are part of a pool these days so,
Lua Code:
  1. for memberFrame in PartyFrame.PartyMemberFramePool:EnumerateActive() do
  2.     print(memberFrame.unit)
  3. end

dragonflyy 10-26-23 10:10 PM

Thank you!


All times are GMT -6. The time now is 08:40 AM.

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