08/26/21, 07:30 PM | #1 |
|
Updating optionData in LAM2
Hey there!
My addon has a list of outfits in the LAM2 settings page. After renaming an outfit, I've noticed it doesn't update in LAM2 until you reload UI. I tried solving it by listening to the event EVENT_OUTFIT_RENAME_RESPONSE but with no luck. Here's my code: Lua Code:
Lua Code:
Lua Code:
|
08/27/21, 02:08 AM | #2 |
This forum here is about asking questions to addons, not lua example code etc.
"The place to ask general questions about developing AddOns." Moved to the correct forum "The place to ask specific questions relating to Lua/XML coding." Last edited by Baertram : 08/27/21 at 02:11 AM. |
|
08/27/21, 02:10 AM | #3 |
There are other threads/posts about this already. Please use the forum search before posting new threads. Searching for LibAddonMenu or LAM would have provided them easily.
But basically you need to use the "reference" tag of the lam options to give it a name you can reference to. And then use <referenceVariableOfDropdownBox>:UpdateChoices(listOfChoices, choicesValues, choicesTooltips) choicesValues and choicesTooltips are optional. But I'd at least always provide choices and choicesValues so that the getfunc and setFunc uses the choicesValues easily, instead of having to check all entries in choices to match the string of your getFunc/setFunc parameter! Searching for LAM or UpdateChoices (you could not know the later until now I assume :-)) will give you example forum threads, e.g. https://www.esoui.com/forums/showthr...=UpdateChoices I've added it to the Wiki as well now: https://wiki.esoui.com/LibAddonMenu:...wn_box_entries Last edited by Baertram : 08/27/21 at 02:49 AM. |
|
08/27/21, 12:46 PM | #4 | |
|
Hey there! Sorry for not searching, definitely will in the future! So I feel like I'm super close but there's something basic I'm not understanding. Here's my attempt to implement what you suggested:
LAM Lua Code:
Update Lua Code:
Event Registers Lua Code:
|
|
08/27/21, 01:24 PM | #5 |
I'm not 100% sure if I understand, so if I'm wrong please forgive me. The LAM menu was not designed with the intent to update or change anything. Meaning if you have a dropdown and the three names are Today, Yesterday, Tomorrow you can not add Next Week after you initialize LAM and then update the dropdown. Nor can you remove Tomorrow and replace it with Next Week.
I am currious because I see an update choices and you can't update them after you call RegisterOptionControls. |
|
08/27/21, 01:26 PM | #6 | |
|
Hmm, yes, that's exactly what I'm trying to do. So is it just an unavoidable shortcoming of my mod that after you rename an outfit you have to ReloadUI for that to take effect in LAM?
|
|
08/27/21, 10:10 PM | #7 |
|
Soooooo I'm not entirely sure how I got this working, but I got it working, haha.
|
08/28/21, 02:59 AM | #8 | |
You can always update existing controls, including the choices in a dropdown. You just cannot add or remove controls after the menu was created. |
||
08/28/21, 09:11 AM | #9 |
08/28/21, 09:30 AM | #10 |
Ok. Guess if you ignore the context of my answer it is a bit confusing.
Let me try to restate it in a way that's harder to misunderstand. LAM was not made with adding or removing controls in mind, so it's not possible to do that. You can however change values of existing controls in various ways which are outlined in the documentation on github. |
|
08/28/21, 11:26 AM | #11 | |
Looks good so far except that you definately should use the 2nd parameter "choicesValues" in the UpdateChoices function as well.
And as the Wiki tells you here: https://wiki.esoui.com/LibAddonMenu:...ntrols_created The LAM controls are NOT created ( means they will be nil ) until you open the LAM settings menu the first time! If you want to update them via events like EVENT_OUTFIT_RENAME_RESPONSE you need to assure the controls exist before! You cannot assume they exist at event_add_on_loaded or event_player_activated! They do not if you have not pressed ESC -> addon settings to show the LAM settings menu, which creates the panels of the registered addons then. So make sure to check if the controls exist via ~= nil before trying to update them and ALWAYS pass in choices = LeonardosWardrobeManager.allOutfits (and like I said before also choicesValues = a table with the key = same as in LeonardosWardrobeManager.allOutfits but the value = the key again (a unique number). So that your setFunc and getFunc can use the key value instead of the name of the outfit to update your savedvariables! Names change! So use a unique key number instead via choicesValues parameter.
|
||
08/28/21, 07:57 PM | #12 |
ESOUI » Developer Discussions » Lua/XML Help » Updating optionData in LAM2 |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|