View Single Post
04/24/14, 09:16 PM   #4
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 660
Originally Posted by Seerah View Post
Aren't you storing the results of Harvest.setting.account in your saved variables?

Are you waiting for EVENT_ADD_ON_LOADED before you actually try to grab stuff from your saved variables?
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("HarvestMap", EVENT_ADD_ON_LOADED, Harvest.OnLoad)
That is at the bottom of the main file.
Lua Code:
  1. function Harvest.OnLoad(eventCode, addOnName)
  2.  
  3.     {{{{ Bunch of stuff here}}}}
  4.  
  5.     Harvest.nodes = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 2, "nodes", { data = {} } )
  6.     if Harvest.settings.account then
  7.         Harvest.settings = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 1, "settings",
  8.         {{{{ stuf }}}}
  9.         }  
  10.     else
  11.         Harvest.settings = ZO_SavedVars:New("Harvest_SavedVars", 1, "settings",
  12.         {{{{ stuf }}}}
  13.         }  
  14.     end
That will error ^^

So I am trying to test add this feature while I have an existing HarvestMap.lua file in Saved Variables. So naturally the file exists but the value is not saved in it yet.

The entire block:
Warning: Spoiler

I don't have an ulterior motive. I'm not expecting you to like download the file and troubleshoot my entire code. However, I'll link it but I don't know how to put it so you know I'm not trying to ask for more then is allowed. Just you want to know something that I may not be doing feel free. That can't sound right but I am trying to be respectful.

What i don't get is when the EVENT_ADD_ON_LOADED fires to run OnLoad, if the value is not there I can't check for nil. If I do it will cause an exception.

Because I tried this:
Lua Code:
  1. if Harvest.settings.account == nil then
  2.     Harvest.settings.account = false
  3. end
But that didn't work.

So what I am worried about is if someone uses HarvestMap 2.3.1, and they upgrade to the new version when I am done, they won't have the setting in the file. When it does not exist how can I define it? So that maybe I can say "Harvest.settings.account = {{{{{ Some Syntax Here }}}". Because I could store the value in two places if that will make it work. I don't know where to specify the default value either.
Lua Code:
  1. if Harvest.settings.account then
  2.         Harvest.settings = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 1, "settings",
  3.             {
  4.                 account = false,
  5.                 filters = {
Am I supposed to do that so there is a default value? And then the next time a user loads their game will it be true if they set it to true?

Last edited by Sharlikran : 04/24/14 at 09:19 PM.
  Reply With Quote