ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   SelectionCampaign variables behavior (https://www.esoui.com/forums/showthread.php?t=10153)

Masteroshi430 04/27/22 01:46 AM

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?

Baertram 04/27/22 02:03 AM

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

Masteroshi430 04/27/22 12:27 PM

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?

sirinsidiator 04/27/22 12:36 PM

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.

Masteroshi430 04/27/22 12:50 PM

Quote:

Originally Posted by sirinsidiator (Post 45789)
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)

Baertram 04/27/22 01:34 PM

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.

Masteroshi430 04/27/22 02:46 PM

Quote:

Originally Posted by Baertram (Post 45791)
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.


All times are GMT -6. The time now is 02:20 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI