View Single Post
11-29-14, 02:33 AM   #4
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Lua Code:
  1. local ZCountSave = {
  2.     ["Count"] = {
  3.         ["ClickedCount"] = 0,
  4.     }
  5. }

Everytime your addon loads this table would be used if it were global and not local. And when your saved variable is loaded which is nil by default it would delete it.
When your main code runs your sv is not yet available. So you want to delay its use after an event that makes sure it is loaded. Typical is ADDON_LOADED (not sure if your implementation works ... as I dont see ZCount defined).

And in repsonse to the event you'd use a construct like

Lua Code:
  1. local default = {
  2.     ["Count"] = {
  3.         ["ClickedCount"] = 0,
  4.     }
  5. ZCountSave = ZCountSave or default

This would make sure your sv is used when available.

Edit:

A quick read should bring more light to this topic
http://wowpedia.org/AddOn_loading_process
http://wowpedia.org/Saving_variables..._game_sessions

A good choice to make sure your data is stored
http://www.wowace.com/addons/ace3/pages/api/ace-db-3-0/
__________________
The cataclysm broke the world ... and the pandas could not fix it!

Last edited by Rilgamon : 11-29-14 at 02:37 AM.
  Reply With Quote