Well, I am making an options menu. Trying to store the bools with var2str
and reclaim them with str2var
with no luck. It keeps saying it can't pull from the dictionary so I must be doing something wrong. I'm not gonna bother posting the header (it's not the problem) but all the var2str
ones are supposed to be bool. Invalid get index "_crt_filter" on dictionary. I should mention my OptionsNode is a global.
## saving settings to dictionary
func _saveOptionsSettings():
_optionsData = {
"_crtFilter" : var2str(_crtFilter),
"_motionFilters" : var2str(_motionFilters),
"_noiseFilters" : var2str(_noiseFilters),
"_noPrompts" : var2str(_noPrompts),
"_itemTextContrast" : var2str(_itemTextContrast),
"_staminaMeterHud" : _staminaMeterHud,
"_globalBgmLevel" : _globalBgmLevel,
"_globalSfxLevel" : _globalSfxLevel,
"_globalVoiceLevel" : _globalVoiceLevel,
"_deadzoneCurrent" : _deadzoneCurrent,
"_hardAnalogAutorun" : var2str(_hardAnalogAutorun),
"_analogRunZone" : _analogRunZone
}
return _optionsData
## saving option file
func _saveOptionsData():
var _myFile = File.new()
_myFile.open(_PREFERENCES, File.WRITE)
_saveOptionsSettings()
_myFile.store_line(to_json(_optionsData))
_myFile.close()
## loading options file
func _loadOptionsData():
var _directory = Directory.new()
if _directory.file_exists(OptionsNode._PREFERENCES):
var _load = File.new()
_load.open(_PREFERENCES,File.READ)
var _loadFile = _load.get_as_text()
parse_json(_loadFile)
_crtFilter = str2var(_optionsData._crtFilter)
_motionFilters = str2var(_optionsData._motionFilters)
_noiseFilters = str2var(_optionsData._noiseFilters)
_noPrompts = str2var(_optionsData._noPrompts)
_itemTextContrast = str2var(_optionsData._itemTextContrast)
_staminaMeterHud = _optionsData._staminaMeterHud
_globalBgmLevel = _optionsData._globalBgmLevel
_globalSfxLevel = _optionsData._globalSfxLevel
_globalVoiceLevel = _optionsData._globalVoiceLevel
_deadzoneCurrent = _optionsData._deadzoneCurrent
_hardAnalogAutorun = str2var(_optionsData._hardAnalogAutorun)
_analogRunZone = _optionsData._analogRunZone
else:
print("No preferences found! Loading defaults.")
_defaultOptionsSettings()