Quantcast
Download
(47 Kb)
Download
Updated: 10/27/18 08:32 AM
Pictures
File Info
Compatibility:
Murkmire (4.2)
Wolfhunter (4.1)
Summerset (4.0)
Dragon Bones (3.3)
Clockwork City (3.2)
Horns of the Reach (3.1)
Morrowind (3.0)
Homestead (2.7)
One Tamriel (2.6)
Shadows of the Hist (2.5)
Dark Brotherhood (2.4)
Thieves Guild (2.3)
Orsinium (2.2.4)
Updated:10/27/18 08:32 AM
Created:05/05/18 10:27 AM
Monthly downloads:267
Total downloads:758
Favorites:1
MD5:
4.2
LibSaveToDisk
Version: 1.3a r5
by: tomtomhotep [More]
This is a library for Addon Authors. If you are a normal user, you have no use for this.

Greetings fellow addon authors.

As we all know, your saved variables aren't saved until the user reloads or logs out. And if their game crashes before that, any changes made to the saved variables are lost!

For some addons, it's not a big deal, but for other addons (like FCOIS or Notebook) it could be HUGE!

One day I lost 30 minutes worth of work setting/changing FCOIS markers and writing out a Guild Mail in Notebook because my game client crashed.

That's when I decided to make this library. It warns the user when one or more addons have substantially changed their saved variables.

What you consider a substantial change is up to you as the addon author using this library.


Just like any other library, get a reference to it with LibStub:


Lua Code:
  1. local STD = LibStub("LibSaveToDisk")


There are 2 library functions you may call:

To register a MAJOR savedvars change with the library:
(i.e. Tell the library you just made a major change)

Lua Code:
  1. STD.CriticalChange("your-addon-name")


To register a MINOR savedvars change with the library:
(i.e. Tell the library you just made a minor change)

Lua Code:
  1. STD.NonCriticalChange("your-addon-name")



There is one major difference between this and the more common libraries:

You must keep the manifest txt file when you embed this library in your addon. Do not remove it!
This is because this library has its own savedVariables file and addon settings panel.

I decided to give this its own settings so the user would have one central place to control how often they want to be bothered by the warning, how long the delay should be when they click "remind me later", and that sort of thing. (See the first screenshot image.)
1.3a r5 - api bump
1.3 r4 - api bump
1.2 r3 - made it so that the Prompt Window does not pop up while in Combat
1.1 r2 - updated LibAddonMenu to r26
1.0 r1 - initial release
Archived Files (4)
File Name
Version
Size
Author
Date
1.3 r4
47kB
tomtomhotep
09/15/18 03:07 PM
1.2 r3
47kB
tomtomhotep
08/11/18 01:07 PM
1.1 r2
47kB
tomtomhotep
05/28/18 11:42 AM
1.0
47kB
tomtomhotep
05/05/18 10:27 AM


Post A Reply Comment Options
Unread 10/27/18, 12:55 PM  
tomtomhotep
 
tomtomhotep's Avatar
AddOn Author - Click to view AddOns

Forum posts: 21
File comments: 166
Uploads: 6
Originally Posted by SlippyCheeze
Does this now handle the addon auto-save stuff appropriately, with the new release?
What auto-save stuff?
Report comment to moderator  
Reply With Quote
Unread 10/27/18, 10:03 AM  
SlippyCheeze
AddOn Author - Click to view AddOns

Forum posts: 52
File comments: 231
Uploads: 1
Does this now handle the addon auto-save stuff appropriately, with the new release?
Report comment to moderator  
Reply With Quote
Unread 05/05/18, 04:42 PM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1800
File comments: 1948
Uploads: 48
Ay, got it. Thanks for the explanation!

Originally Posted by tomtomhotep
Originally Posted by Baertram
I like the idea thanks for the lib.
But I do not really understand how this works, maybe you could explain it a bit more or add more description text to the library's description:

If I just register my addon name to the function
Lua Code:
  1. STD.CriticalChange("your-addon-name")
:

How does it check if something was changed or not within the addon?
And is every change within the savedvars of this addon affected then, or only some?
What's the difference between critical and non-critical changes then?

Thanks for an explanation.

No, wrong concept. The library can't tell when your saved variables change. YOU must tell IT.

You call CriticalChange whenever YOU make whatever YOU consider to be a "major" change of saved variables. (like in FCOIS maybe when user does /fcois backup)

You call NonCriticalChange whenever YOU make whatever YOU consider to be a "minor" change of saved variables.

What you consider major or minor is completely up to you.

The addon then prompts the user according to their settings for LibSaveToDisk.

With default settings, they should be prompted less than 15 seconds after any addon calls CriticalChange, unless the user set a minimum minutes between critical change warnings.

Basically, call CriticalChange if you think the user should reloadui as soon as possible.


"non-critical" (or minor) changes are counted by the library until NonCriticalChange has been called x times (by any and all addons), where x is the user's setting for "Minimum Non-critical Changes" (default 10, slider currently allows 1 to 40). When that count reaches x, the user is prompted to reloadui.



Oh, and if the user clicks "I'll Take My Chances" on the warning window, all counters are reset to 0, but the library is not disabled, i.e. new calls to the library functions still perform the same.
Report comment to moderator  
Reply With Quote
Unread 05/05/18, 02:01 PM  
tomtomhotep
 
tomtomhotep's Avatar
AddOn Author - Click to view AddOns

Forum posts: 21
File comments: 166
Uploads: 6
Originally Posted by Baertram
I like the idea thanks for the lib.
But I do not really understand how this works, maybe you could explain it a bit more or add more description text to the library's description:

If I just register my addon name to the function
Lua Code:
  1. STD.CriticalChange("your-addon-name")
:

How does it check if something was changed or not within the addon?
And is every change within the savedvars of this addon affected then, or only some?
What's the difference between critical and non-critical changes then?

Thanks for an explanation.

No, wrong concept. The library can't tell when your saved variables change. YOU must tell IT.

You call CriticalChange whenever YOU make whatever YOU consider to be a "major" change of saved variables. (like in FCOIS maybe when user does /fcois backup)

You call NonCriticalChange whenever YOU make whatever YOU consider to be a "minor" change of saved variables.

What you consider major or minor is completely up to you.

The addon then prompts the user according to their settings for LibSaveToDisk.

With default settings, they should be prompted less than 15 seconds after any addon calls CriticalChange, unless the user set a minimum minutes between critical change warnings.

Basically, call CriticalChange if you think the user should reloadui as soon as possible.


"non-critical" (or minor) changes are counted by the library until NonCriticalChange has been called x times (by any and all addons), where x is the user's setting for "Minimum Non-critical Changes" (default 10, slider currently allows 1 to 40). When that count reaches x, the user is prompted to reloadui.



Oh, and if the user clicks "I'll Take My Chances" on the warning window, all counters are reset to 0, but the library is not disabled, i.e. new calls to the library functions still perform the same.
Report comment to moderator  
Reply With Quote
Unread 05/05/18, 01:09 PM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1800
File comments: 1948
Uploads: 48
I like the idea thanks for the lib.
But I do not really understand how this works, maybe you could explain it a bit more or add more description text to the library's description:

If I just register my addon name to the function
Lua Code:
  1. STD.CriticalChange("your-addon-name")
:

How does it check if something was changed or not within the addon?
And is every change within the savedvars of this addon affected then, or only some?
What's the difference between critical and non-critical changes then?

Thanks for an explanation.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: