This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

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.

in Engine by (50 points)
retagged by

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

1 Answer

+1 vote
Best answer

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.

by (1,892 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.