I use a resource (SaveData.res) to serialize some values in my game. Everything is saved properly when I inspect the res file except for booleans. When the var gets the default value, the line (var name and value) are erased from the resource file. I've seen Godot do some optimizations when value does not change but in this case, the line is completely removed from my resource file. For instance, the var starts to false and is written in the resource but when I turn it to true and save, the line disappear from the file.
Is there a problem there?
A default value is implicit so it doesn’t have to be explicitly saved. It’s redundant. If the loader doesn’t find the value override in the resource file - it will just use the default value. So you’ll always get the correct value back.
I get your point but I’m balancing clarity / explicit vs performance here. I would like to have the choice to keep this line in my resource file no matter if it has the default value or not.
I’ve worked around by using an int but I’d hope there is another way so if you know any.
When I debug, I do prefer see the line being written with its value. If the line is not there, it’s harder to konw whether the writing file is the issue or if it’s because it has the default value and had been optimized.
Also, when looking at the file, it’s hard to remember every field that should be there, so if the file is empty because everything is at its default value I would have to read a blank file.
Again, I’m not sure the optimization it brings worth the lack of clarity but maybe I’m wrong.
besides, isn’t it a problem to optimize the file ?
imagine you test your game and everything looks fine but once in the wild, some players have found a way to change all the values, thus no optimization can be made… in this case, I would rather have noticed it before. no ?