-
Posted by omirr on Thu, 04 Aug 2011 11:55:58
Hello,
I'm writing a looting addon for my guild, or at least attempt to, so I can see how far I get. It's getting along nicely. I've made a frame that pops up when something of relevance is looted. This frame has like 15 child frames, and each of those has a number of buttons (created with a template). In order to access those buttons I'm using a table so I can shorten my code a bit, but this doesn't seem like an elegant solution. So my question, is there a way to access the frames (buttons) without this table?
SDKP_LootFrame_Item_Button_MS_Table = {}; SDKP_LootFrame_Item_Button_MS_Table[1] = SDKP_LootFrame_Item1_Button_MS; SDKP_LootFrame_Item_Button_MS_Table[2] = SDKP_LootFrame_Item2_Button_MS; SDKP_LootFrame_Item_Button_MS_Table[3] = SDKP_LootFrame_Item3_Button_MS; SDKP_LootFrame_Item_Button_MS_Table[4] = SDKP_LootFrame_Item4_Button_MS; SDKP_LootFrame_Item_Button_MS_Table[5] = SDKP_LootFrame_Item5_Button_MS; SDKP_LootFrame_Item_Button_MS_Table[6] = SDKP_LootFrame_Item6_Button_MS; SDKP_LootFrame_Item_Button_MS_Table[7] = SDKP_LootFrame_Item7_Button_MS; SDKP_LootFrame_Item_Button_MS_Table[8] = SDKP_LootFrame_Item8_Button_MS; SDKP_LootFrame_Item_Button_MS_Table[9] = SDKP_LootFrame_Item9_Button_MS; SDKP_LootFrame_Item_Button_MS_Table[10] = SDKP_LootFrame_Item10_Button_MS;
then accessing with
SDKP_LootFrame_Item_Button_MS_Table[buttonnrInt]:Disable()
you get the idea
-
Posted by jnwhiteh on Thu, 04 Aug 2011 11:57:29
Either you can look them up using their names in the global environment G["SDKPLootFrameItem1Button_MS"] or you can do what you're already doing. Either way you're using a table to look them up =)
-
Posted by jnwhiteh on Thu, 04 Aug 2011 11:59:07
You can easily make that table local and shorten the name quite a bit.
-
Posted by omirr on Thu, 04 Aug 2011 11:59:31
Wauw fast reply.
So, I could concatenate the name together and the look it up in the global environment and basically going through a bigger table. Is doing that less performant and should I stick to what I'm doing atm?
edit: Yeah will shorten the names after I'm done with everything.. easier to just Find+Replace. Keeping the long names for clarity atm.
-
Posted by jnwhiteh on Thu, 04 Aug 2011 12:02:29
What you are doing is the best way to do it, to be honest!
-
Posted by omirr on Thu, 04 Aug 2011 12:03:24
Okay ty for the help !! :)