This is for my first ever game, and im working on the saving system. It's going to be published on Android. I have the system saving the basic stats, but the file doesn't seem to be saving and I keep getting this error "Condition '!f' is true" at the line where I call the storeline(tojson()). This happens when ever I call my function Save_Game, it keeps calling this error, it doesn't crash the game but it doesn't do what it's supposed to. Which is to save the game!
Here is the function:
func save_game():
var save_game = File.new()
save_game.open(save_path, File.WRITE)
var save_nodes = get_tree().get_nodes_in_group("DataHolder")
for i in save_nodes:
var node_data = i.call("save_data");
save_game.store_line(to_json(node_data))
save_game.close()
Now it's calling another function from a different node called 'Player Stats' and that function saves the data in a directory. Here is that code:
func save_data():
var save_dict = {
"filename" : get_filename(),
"parent" : get_parent().get_path(),
"Health" : hp,
"Action" : ap,
"Mana" : mp
}
return save_dict
And this all starts when I press the button which calles the function save_game, heres that code just in case:
func _on_pressed():
var playerStats = BATTLE_UNITS.playerStats
get_node("/root/SaveSystem").save_game()
These are all that relate to the save system, I can't tell what the error is, and how to fix it. Some help would be awesome, for this is my first time with a save system.