I need to add a single one line value to the HarvestMap.lua that I read first thing when the mod loads. I need to get a boolean value right away first thing.
Lua Code:
Harvest.nodes = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 2, "nodes", { data = {} } )
if Harvest.settings.account then
Harvest.settings = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 1, "settings",
{{{{ A bunch of stuf here }}}}
}
else
Harvest.settings = ZO_SavedVars:New("Harvest_SavedVars", 1, "settings",
{{{{ A bunch of stuf here }}}}
}
end
That is what loads so I get an exception because Lua does not know what the value of Harvest.settings.account is. Harvest settings account is defined with LAM.
Lua Code:
LAM:AddHeader(panelID, "HarvestSettingsHeader", "Account Wide Settings")
LAM:AddCheckbox(panelID, "HarvestMapSettings", "Account Wide Settings", "Enable account Wide Settings",
function()
return Harvest.settings.account
end,
function( value )
Harvest.settings.account = value
ReloadUI()
end,
false, nil)
Side question: did I define that correctly with LAM so that the UI Will reload ONLY when a player changes the value?
So what I was looking for was how to have it be something like this:
Lua Code:
???? Harvest.settings.account = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 1, "accountWideBool", accountWideBool ) {{----The line I want to add ----}}
Harvest.nodes = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 2, "nodes", { data = {} } )
if Harvest.settings.account then
Harvest.settings = ZO_SavedVars:NewAccountWide("Harvest_SavedVars", 1, "settings",
{{{{ A bunch of stuf here }}}}
}
else
Harvest.settings = ZO_SavedVars:New("Harvest_SavedVars", 1, "settings",
{{{{ A bunch of stuf here }}}}
}
end
If I don't put any lines that will cause an exception, with LAM the boolean setting will be written to the settings file as "["account"] = false," so I know it will be there at some point. However, I want to get that value, but, if it's not there I want the default to be false. Naturally I can change the AddCheckbox routine in lam to have a different value, like Harvest.accountWidePrefs. I just don't know what to change it to so that it gets the setting right away and doesn't cause an exception.
What is the proper syntax?