WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   How can I detect is an install of my addon is new or an update? (Ace3) (https://www.wowinterface.com/forums/showthread.php?t=57417)

yess 09-02-19 12:31 PM

How can I detect is an install of my addon is new or an update? (Ace3)
 
I just noticed that if I change the default table given to AceDB it will also change for current installations of the addon when the user updates it.

This did upset a few user. How can I distinguish between update and new install.

Is saving the addons version and then comparing it good idea?

Xrystal 09-02-19 04:26 PM

If I add a new variable to the default data table I just preset that value and add it to the existing data.


dataTable = dataTable or {}
.. if dataTable is Empty set to default values
.. Add new Data

This way if they have installed a new addon with no data it will create it, if they already have data it will just add a default version of the new data.

If you need them to reset their data for an update due to changes just make sure that information is provided in the patch file and/or main addon page so that they know they may need to go through their settings again.


I think nUI used the version number system and had a function run through that checked which version was last used by the player and the new version and make any necessary changes to the data at that point before setting the new version as the new last used.

Edit: After all that, I just noticed the Ace3 in the title rofl. I haven't used their library so can't help in that particular area. But hopefully someone will be able to help you. Good Luck.

Ketho 09-02-19 04:35 PM

Quote:

Originally Posted by yess (Post 333536)
I just noticed that if I change the default table given to AceDB it will also change for current installations of the addon when the user updates it.

This did upset a few user.


It's magic, so any defaults that were not changed by the user are changed to the new version of your default table. I don't understand how users would get upset by that. It should be intended functionality

Quote:

Originally Posted by yess (Post 333536)
How can I distinguish between update and new install.

Is saving the addons version and then comparing it good idea?


Yes you could probably try saving the addon version somewhere in the AceDB SavedVariables or a separate savedvar and then compare

Not sure how you would not change any current installations while still being able to change the default table for newer versions unless you want to keep multiple versions around of your default table when passing it to AceDB

yess 09-04-19 07:01 AM

Quote:

unless you want to keep multiple versions around of your default table when passing it to AceDB
Yes that is what I ended up doing so far.

Quote:

It's magic, so any defaults that were not changed by the user are changed to the new version of your default table. I don't understand how users would get upset by that. It should be intended functionality
Because an update changes their settings. i do understand that they do not want that.

Seerah 09-04-19 12:26 PM

The way I understand AceDB (I don't use it myself) is that it only stores settings a user has changed from the default. If a user is still using a default setting (even if just 1 out of 20), it won't bother to write that 1 to file.

It is good practice to give a lot of careful thought to what your default options are when creating them. It is not always a good idea to change those defaults on users unless you have a very good reason to do so. In this case, it is prudent to alert users that the defaults are changing. If the old default setting still exists as an option, they may be a touch inconvenienced, but can get it back to the way they are used to.

myrroddin 09-05-19 10:57 PM

Quote:

Originally Posted by Seerah (Post 333577)
The way I understand AceDB (I don't use it myself) is that it only stores settings a user has changed from the default. If a user is still using a default setting (even if just 1 out of 20), it won't bother to write that 1 to file.

Correct.
Code:

local defaults = {
    profile = {
        enabled = true,
        pet = "dog"
    }
}

Let's first assume the user changes nothing, in which case there is no file written in the SavedVariables folder. Next, let's assume the user changes pet = "cat". In this case, a file is created, containing something like this:
Code:

MyAddOnDB = {
    ["Seerah - Lightbringer"] = { -- if the character "Seerah" was on the realm "Lightbringer"
        pet = "cat",
    },
}

You will notice that there is no entry for "enabled" because that was not changed by the user, and is still the default.


All times are GMT -6. The time now is 08:12 PM.

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