View Single Post
08/29/19, 05:04 AM   #5
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
The trading house is a bit of a different beast than the regular inventory and you cannot simply hook into it in the events mentioned by Baertram, because it will only fully initialize the first time you actually visit a guild store.

The best way I have found so far is to hook into TRADING_HOUSE:SetCurrentMode and use a flag to run the code only the first time it is called.

Lua Code:
  1. local ranInitialSetup = false
  2. ZO_PreHook(TRADING_HOUSE, "SetCurrentMode", function()
  3.     if(ranInitialSetup) then return end
  4.     ranInitialSetup = true
  5.  
  6.     -- do your setup here
  7. end)

or you can use AwesomeGuildStore as a dependency for your addon and listen to its AFTER_INITIAL_SETUP callback, with the additional advantage that it will already have applied its changes.

Lua Code:
  1. local AGS = AwesomeGuildStore
  2. AGS:RegisterCallback(AGS.callback.AFTER_INITIAL_SETUP, function()
  3.     -- do your setup here
  4. end)
  Reply With Quote