Thread Tools Display Modes
04/27/22, 01:46 AM   #1
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 185
SelectionCampaign variables behavior

Hi there!
Correct me if I am wrong but it looks like variables like GetNumSelectionCampaigns() or GetSelectionCampaignPopulationData(,) are only populated after the alliance war menu has been opened once.

Is there a workaround for this?
  Reply With Quote
04/27/22, 02:03 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,963
Not that I know off. There are a lot of these deferred init codings, especially in GamepadMode: Inventory lists etc. first init as you open them the 1st time

But even in keyboard mode there are some of them, like the Campaigns and the Dungeons list (Groupfinder), the worldmap (to read some POI data etc).

So you could need to add a scene/fragment StateChange callback, check for newState == SCENE(_FRAGMENT)_SHOWN and then react on it.

Maybe (meanwhile) there are some *_MANAGER globals which one is able to use to get the data by other means, like the "collectibles" got the ZO_COLLECTIBLE_DATA_MANAGER

-> CAMPAIGN_BROWSER_MANAGER (if this is the correct one, it is a ZO_Callback object so you can register a callback here too as it is doing stuff, e.g.
CAMPAIGN_BROWSER_MANAGER:RegisterCallback("OnCampaignDataUpdated", function() ... end) )


If this does not help try to open the menu of the campaigns by calling the same code that the keybind does, and then register the scene/fragment callback to see when it is finally SCENE_SHOWN -> run your code then

Last edited by Baertram : 04/27/22 at 02:08 AM.
  Reply With Quote
04/27/22, 12:27 PM   #3
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 185
I managed to open/close the alliance war menu very quickly 1 second after addon starts and the data is populated
It's so fast we can only hear the "open menu" sound, the icing on the cake would be muting that sound while doing it so it would totally be a background task to the user.
I don't know if it is possible?
  Reply With Quote
04/27/22, 12:36 PM   #4
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
The api function to trigger a load should be "QueryCampaignSelectionData".
The reason why it is not automatically loaded all the time for every user is because it's heavy on the server. Keep in mind that if you work around it and automatically load it all the time, they may need to lock down the api so addons can no longer use it (like they did for the guild history). Ideally you should only query the data in response to user actions and not in background just because you can.
  Reply With Quote
04/27/22, 12:50 PM   #5
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 185
Originally Posted by sirinsidiator View Post
The api function to trigger a load should be "QueryCampaignSelectionData".
The reason why it is not automatically loaded all the time for every user is because it's heavy on the server. Keep in mind that if you work around it and automatically load it all the time, they may need to lock down the api so addons can no longer use it (like they did for the guild history). Ideally you should only query the data in response to user actions and not in background just because you can.
It's just one load 1 second after addon start and then unregister from EVENT_ADDON_LOADED just after.
No other loads are made after that.
Do you think that is too much ? (I have no idea)
  Reply With Quote
04/27/22, 01:34 PM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,963
It's not about the 1 second time it needs and how you do it as Siri said, it's about "that you do it every time at least once automatically" if the addon is enabled.
So each addon user with your addon will stress the server +1 due to that where it only should do this as they manually open the campaigns normally (that's how ZOs designed it and how the server expects it to happen. Your additional +1 will double/tripple/... based on done reloaduis and event_add_on_loaded firing + 1) the stuff at least for these users, which sums up in total at the server's "needed answers" for your queries).

At best: Nothing we should worry about. But your addon is only 1 of many, and you never know how many users will install and use it. You always need to keep that "sum of queries that addons will raise at the server" in mind.
At worst: Ths behavior will "just because it was possible" will lead to an API change and lock down of these methods, like the guild history, guild messages and other stuff already was due to "only 1 quick...whatever" producing server lag/problems.

Last edited by Baertram : 04/27/22 at 01:37 PM.
  Reply With Quote
04/27/22, 02:46 PM   #7
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 185
Originally Posted by Baertram View Post
It's not about the 1 second time it needs and how you do it as Siri said, it's about "that you do it every time at least once automatically" if the addon is enabled.
So each addon user with your addon will stress the server +1 due to that where it only should do this as they manually open the campaigns normally (that's how ZOs designed it and how the server expects it to happen. Your additional +1 will double/tripple/... based on done reloaduis and event_add_on_loaded firing + 1) the stuff at least for these users, which sums up in total at the server's "needed answers" for your queries).

At best: Nothing we should worry about. But your addon is only 1 of many, and you never know how many users will install and use it. You always need to keep that "sum of queries that addons will raise at the server" in mind.
At worst: Ths behavior will "just because it was possible" will lead to an API change and lock down of these methods, like the guild history, guild messages and other stuff already was due to "only 1 quick...whatever" producing server lag/problems.
Ok I have it working good but I won't use it that way and will trigger it when users close the alliance war menu, that way it will be no added load. Thanks.

Last edited by Masteroshi430 : 04/27/22 at 03:34 PM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » SelectionCampaign variables behavior

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off