View Single Post
01/29/15, 04:05 PM   #21
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
There are some UI objects that are difficult to get hold of, because they're only kept in local variables.

ingame/mainmenu/mainmenu.lua
Function ZO_MainMenuManager:Initialize creates an instance of ZO_AddOnManager, and puts it in a local variable. In AddonProfiles, I override ZO_AddOnManager:OnShow with the sole purpose of getting that instance. If not global, it could at least be a member in ZO_MainMenuManager (MAIN_MENU).

ingame/campaign/campaignbrowser.lua
CAMPAIGN_BROWSER is local in this file
Again, I was able to get it, but this one required a dirty hack. As to what for, it's a not-yet-ready add-on that flattens campaign tree, so that all (Normal) campaigns appear in one list.

ingame/leaderboards/leaderboards_shared.lua
And now for something completely different. Function ZO_LeaderboardsListManager_Shared:IndexFunction, which is used to implement __index meta-method on data tables, returns dataTable[key]. As long as every accessed key either exists or is added in SetupDataTable, it works. But when someone foolish enough attempts to access dataTable.foobar, it will lead to infinite recursion. Yes, I learned that the hard way The function should return rawget(dataTable, key).
  Reply With Quote