Go to Page... |
|
Thread Tools | Display Modes |
|
01/25/16, 02:35 AM | #1 |
|
Having issues creating an account-wide settings toggle
Hi, I'm having trouble create an 'account-wide settings' toggle for one of my addons, well actually I've got it working but its causing weird behavior with the colorpicker controls and some of the other controls, and I'm hoping someone can help me figure out what I'm doing wrong, here is some scippets of how I'm accomplishing the accountwide toggle:
When my addon loads here is how I load the settings: Lua Code:
and here is how my 'Account-Wide' toggle is setup (using libaddonmenu): Lua Code:
Just for reference here is how the Colorpicker is setup: Lua Code:
I'm using SimpleXPBar.CurSV to reference my settings through-out the rest of the code, and the issue I'm having with the colorpicker is that it keeps flipping back and forth between 2 different color settings everytime I click it, I have a feeling this has to do with how lua is referencing the object but I cant figure what its doing in this case. I've already searched around the forums and google trying to find some sample of how to create a accountwide toggle correctly but I ended up looking at how Destinations and MasterMerchant do it and trying something similar. Any suggestions on a better way of implementing this or a fix would be appreciated. |
01/25/16, 04:52 AM | #2 |
|
What I see at the first glance is this
Lua Code:
Doesn't that mean you use AWSV to save new changes but copy the data from CharSV (that didn't change) over that every time you reload UI? That would reset it to whatever is in CharSV. But maybe ZO_DeepTableCopy is the other way round, don't know. Edit: Either way I think it has to be the ZO_DeepTableCopy function, my solution was pretty much the same, just without copying tables around (why would you do that anyways?). Lua Code:
Last edited by coolmodi : 01/25/16 at 05:26 AM. |
01/25/16, 06:20 AM | #3 | ||
|
|
||
01/25/16, 06:45 AM | #4 |
|
I'm pretty much still a noob in programming, but as I understand it LUA will always reference tables, but "copy" other values.
Lua Code:
There's also something called metatables that can change the behavior of tables, ZO_DeepTableCopy ignores them, maybe that messes something up. In GroupDamage I used a custom deepcopy function because I didn't know the ZOS one existed and only because of that even stumbled over this topic. Maybe that's worth a try? Lua Code:
But again, I'm really no pro here, and maybe the error is somewhat completely different that we both just don't see |
01/25/16, 07:55 AM | #5 |
While reloading the UI when you toggle the checkbox may solve the problem, it makes for a horrible user experience. Especially when there are multiple settings that each want to reload the ui for themselves, so please use it only as a last resort when there is absolutely no other way to get around it and even then, consider adding a reload ui button instead of automatically reloading it. This advice is also meant for other authors that use forced UI reloads.
As for your problem, I think there are three issues. 1) When you replace the currently used variables in your set function you also need to inform LAM that something changed, so that it can render the changes in its controls. This can be done by firing the "LAM-RefreshPanel" callback: Lua Code:
2) ZO_SavedVars is a highly complex object. I am not sure if ZO_DeepTableCopy is enough to replace the values correctly. I don't personally use ZO_SavedVars, so correct me if I am wrong, but I think the right way to accomplish what you want is to just create a new ZO_SavedVars object and pass the values that need to be copied as defaults. 3) LAM may call setFunc more often than necessary (not 100% sure, but it might happen), so you should check if something changed before doing your copy routine. With all of these things considered, it should look something like this: Lua Code:
|
|
01/25/16, 08:42 AM | #6 | |
|
He should just make a function himself that sets all settings to the ones from the other SV and doesn't change the tables. That way it would work for sure. And yes, the reload in my code there isn't needed, I could just change the reference and it should work fine. Last edited by coolmodi : 01/25/16 at 08:46 AM. |
|
01/25/16, 07:05 PM | #7 | |
|
|
|
01/25/16, 08:22 PM | #8 |
|
Well I spoke too soon, it wouldn't let me set accountwide settings when I did that, seems nothing I try lets me copy over another table, aside from writing a large function to manually copy over all the vars.
For now I'll just keep character and account settings in separate SavedVars, this means the user should enable the Account-Wide toggle before making any changes. checkbox Lua Code:
At playerload Lua Code:
|
ESOUI » Developer Discussions » Lua/XML Help » Having issues creating an account-wide settings toggle |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Hybrid Mode |
Switch to Threaded Mode |
|
|