Join Date: Apr 2014
Posts: 660
|
Originally Posted by Seerah
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:
EVENT_MANAGER:RegisterForEvent("HarvestMap", EVENT_ADD_ON_LOADED, Harvest.OnLoad)
That is at the bottom of the main file.
Lua Code:
function Harvest.OnLoad(eventCode, addOnName) {{{{ Bunch of stuff here}}}} Harvest.nodes = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 2, "nodes", { data = {} } ) if Harvest.settings.account then Harvest.settings = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 1, "settings", {{{{ stuf }}}} } else Harvest.settings = ZO_SavedVars:New("Harvest_SavedVars", 1, "settings", {{{{ stuf }}}} } 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
Lua Code:
function Harvest.OnLoad(eventCode, addOnName) if addOnName ~= "HarvestMap" then return end -- NEW keep these they init things Harvest.isHarvesting = false Harvest.action = nil Harvest.NumbersNodesAdded = 0 Harvest.NumFalseNodes = 0 Harvest.NumContainerSkipped = 0 Harvest.NumbersNodesFiltered = 0 Harvest.NumNodesProcessed = 0 Harvest.minDist = 0.000025 -- 0.005^2 Harvest.nodes = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 2, "nodes", { data = {} } ) if Harvest.settings.account then Harvest.settings = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 1, "settings", { filters = { -- [0] = true, [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true [0] = true, [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true, [7] = true, [8] = true }, -- Import filters false by default so they are imported importFilters = { [0] = false, [1] = false, [2] = false, [3] = false, [4] = false, [5] = false, [6] = false, [7] = false, [8] = false }, -- Gather filters true by default so they are gathered gatherFilters = { [0] = false, [1] = false, [2] = false, [3] = false, [4] = false, [5] = false, [6] = false, [7] = false, [8] = false }, mapLayouts = Harvest.defaultMapLayouts, compassLayouts = Harvest.defaultCompassLayouts } ) else Harvest.settings = ZO_SavedVars:New("Harvest_SavedVars", 1, "settings", { filters = { -- [0] = true, [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true [0] = true, [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true, [7] = true, [8] = true }, -- Import filters false by default so they are imported importFilters = { [0] = false, [1] = false, [2] = false, [3] = false, [4] = false, [5] = false, [6] = false, [7] = false, [8] = false }, -- Gather filters true by default so they are gathered gatherFilters = { [0] = false, [1] = false, [2] = false, [3] = false, [4] = false, [5] = false, [6] = false, [7] = false, [8] = false }, mapLayouts = Harvest.defaultMapLayouts, compassLayouts = Harvest.defaultCompassLayouts } ) end if (Harvest.nodes.internalVersion or 0) < internalVersion then Harvest.updateNodes(Harvest.nodes.internalVersion or 0) Harvest.nodes.internalVersion = internalVersion end Harvest.InitializeMapMarkers() Harvest.InitializeCompassMarkers() Harvest.InitializeOptions() EVENT_MANAGER:RegisterForEvent("HarvestMap", EVENT_LOOT_RECEIVED, Harvest.OnLootReceived) EVENT_MANAGER:RegisterForEvent("HarvestMap", EVENT_LOOT_UPDATED, Harvest.OnLootUpdate) end EVENT_MANAGER:RegisterForEvent("HarvestMap", EVENT_ADD_ON_LOADED, Harvest.OnLoad)
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:
if Harvest.settings.account == nil then Harvest.settings.account = false 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:
if Harvest.settings.account then Harvest.settings = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 1, "settings", { account = false, 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.
|