An Error in the store_line function keeps saying "Condition '!f' is true" and I have no idea what that means

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Dead_lucky_32

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 store_line(to_json()). 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.

Do you get the issue when you export to Android or in the editor too?

johnygames | 2019-12-27 08:23

:bust_in_silhouette: Reply From: johnygames

Eureka! It is highly probable that your save_path is wrong. Check that this path exists and that it is written correctly (paths are case sensitive). The format should be: C:/directory/directory/filename.extension. Notice that I used the forward slash.

If this solves your problem, let me know.

That seemed to have fixed it! Thank you so much, that got rid of the bug, and it’s not creating the save file! Thank you for that

Dead_lucky_32 | 2019-12-27 15:14