ERROR: store_line: Condition ' !f ' is true.

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

Hey people,

I’m having a strange error saving a game to a .json file.
The error I’m getting is “ERROR: store_line: Condition ’ !f ’ is true.”
It seems to come from the line of code “save_game.store_line(to_json(fases))”
This is not crashing the game and the game saves and loads normally (both exported and inside the editor).
It’s really annoying though.
Any clue to what could be causing it?

The code:

func saveGame():
	var save_game = File.new()
	save_game.open("user://data.save", File.WRITE)
	save_game.store_line(to_json(fases))
	save_game.store_line(to_json(picks))
	save_game.store_line(to_json(disp))

*fases, picks and disp are just lists with 1s and 0s

Thanks!

:bust_in_silhouette: Reply From: wombatstampede

I checked core\bind\core_bind.cpp ( https://github.com/godotengine/godot/blob/master/core/bind/core_bind.cpp ) and it seems that this indicates that your file (savegame) hasn’t been successfully opened before calling store_line.

This may be due to multiple reasons. (which I can’t tell because you didn’t post some code)
I.e.: you tried to save your savegame in a res:// path which might fail on exported projects. (res:// is readonly on some platforms).
or: you simply did not create/open the file before before the first store_line

Hey thanks for the answer
I think I can rule out the second example
I updated my question with some code

Tatuzudo | 2019-11-15 23:06

#1: Please check the return code from open(). If it is != OK then output the error code
( @GlobalScope — Godot Engine (3.1) documentation in English )

#2: Personally, I think it is good style to close() the file after use. The destructor may do so implicitly but maybe it does it deferred which may lead to a problem if another file write attempt is done before the close has happened.

#3: If the messages still ocur then try to put some print() before and after the store_line() to see if the error occurs where exactly, every time (also on the first call) and if the error even happens on that spot and not in another location which you weren’t aware of.

wombatstampede | 2019-11-16 12:38

Looks like closing the file solved the problem.
Thank you very much!

Tatuzudo | 2019-11-16 19:06