I'm still fairly new to Ace3, but have made a few addons without, so I have a fairly strong understanding of coding in WoW Lua. With that said, I have a question that I'm having difficulty finding an answer for.
I'm trying to access a frame I made in a secondary file from my "core" file. Does Ace3 have special coding functionality to handle this, or do I have to stick to the generic "local addon, global = ..." variable?
Ace3 itself does not have anything for sharing data across files. Your best bet is, as you suspect, to use the "local addonName, sharedTable = ..." and stick something inside sharedTable.
Note that if you're using AceAddon, the :NewAddon() function optionally takes a table as its first argument, and will build the addon's infrastructure inside that table instead of creating a new table. If you pass the sharedTable pointer as that argument, your core file can then look like
local addonName, addon = ...
-- ... stuff ...
addon = LibStub("AceAddon-3.0"):NewAddon (addon, addonName, "other", "libraries", "here")
function addon:OnWhatever()
... self.myFrame ...
end
and other files loaded later in the .toc can be
local addonName, addon = ...
addon.myFrame = CreateFrame(..........)
I'm still fairly new to Ace3, but have made a few addons without, so I have a fairly strong understanding of coding in WoW Lua. With that said, I have a question that I'm having difficulty finding an answer for.
I'm trying to access a frame I made in a secondary file from my "core" file. Does Ace3 have special coding functionality to handle this, or do I have to stick to the generic "local addon, global = ..." variable?
Thanks!
Note that if you're using AceAddon, the :NewAddon() function optionally takes a table as its first argument, and will build the addon's infrastructure inside that table instead of creating a new table. If you pass the sharedTable pointer as that argument, your core file can then look like
and other files loaded later in the .toc can be
The global variable MyAwesomeFrame now refers to the created frame, and by virtue of being global is available to any code in any file in any addon.
Typically you should give your main frame a global name, and then attach all its children to keys on it: