![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ricardohogan |
I’m making a save system to save my game currentlevel progress (for example its saves when I unlocked level 2, and so i dont start over level 1 again).
Im following a tutorial from GDquest https://www.youtube.com/watch?v=IrUhyf-g5hU and it works well on windows when I use const SAVE_PATH = "res://config.cfg"
.
The problem occur when I debug it to my Android. it just doesnt work. please help, thx
extends Node
const SAVE_PATH = "user://config.cfg"
var _config_file = ConfigFile.new()
var _saved_data = { "current_level" : { "level" : 1 }}
func _ready():
load_settings()
if _saved_data["current_level"]["level"] != _config_file.get_value("current_level","level"):
_saved_data["current_level"]["level"] = _config_file.get_value("current_level","level")
set_fixed_process(true)
func save_settings():
for section in _saved_data.keys():
for key in _saved_data[section]:
_config_file.set_value(section, key, _saved_data[section][key])
_config_file.save(SAVE_PATH)
func load_settings():
var error = _config_file.load(SAVE_PATH)
if error != OK:
print("Failed" % error)
return[]
for section in _saved_data.keys():
for key in _saved_data[section]:
_config_file.get_value(section,key,null)
func _fixed_process(delta):
if _saved_data["current_level"]["level"] != _config_file.get_value("current_level","level"):
save_settings()
print(_saved_data["current_level"]["level"])