Thread Tools Display Modes
09-02-19, 12:31 PM   #1
yess
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 29
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?
  Reply With Quote
09-02-19, 04:26 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
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.
__________________

Last edited by Xrystal : 09-02-19 at 04:30 PM.
  Reply With Quote
09-02-19, 04:35 PM   #3
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by yess View Post
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

Originally Posted by yess View Post
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

Last edited by Ketho : 09-02-19 at 06:17 PM.
  Reply With Quote
09-04-19, 07:01 AM   #4
yess
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 29
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.

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.
  Reply With Quote
09-04-19, 12:26 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
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.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-05-19, 10:57 PM   #6
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by Seerah View Post
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.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How can I detect is an install of my addon is new or an update? (Ace3)

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