Godot-proposals: Warning when unlisted JSON (and other) files are accessed in the FIleSystem

Created on 24 Aug 2020  路  6Comments  路  Source: godotengine/godot-proposals

Describe the project you are working on:
Cave survey VR

Describe the problem or limitation you are having in your project:
For some reason JSON files do not appear in the FileSystem docked window even when they are in the underlying directory and they can still be opened from GDscript.

The problem comes when you deploy the game to another machine and your unlisted JSON file doesn't get included in the bundle.

This issue took me a while to track down and it is unfortunate.

(I would say it is a surprise that JSON files are not considered a resource, given the support for them in the core libraries. It's a useful format for porting game level data created by your legacy scripts into your new Godot game, and is just as common as PNG or JPG file formats. The work-around is to put a ".res" at the end of the file and point the json parser at it, but it shouldn't be necessary to do this. Similar observations have been made at https://github.com/godotengine/godot/issues/24186)

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
This warning feature would help people identify a problem they will have on deployment while they are still working in their development environment.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
There should be a Debug Warning/Error option when I open a file from the resource directory "res://something.json"
and it is not listed in the FileSystem and is therefore not going to be included when the game gets deployed to another machine.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
Not applicable

Is there a reason why this should be core and not an add-on in the asset library?:
Not applicable

core

Most helpful comment

Thought: files whose extension matches a custom resource type defined in the export settings should be displayed in the file dock, even if there is no means of opening them within godot.

All 6 comments

2 things:

1) when you export the game, you can list extensions for additional files to include in the resource pack.

2) it's trivial to create an addon that makes .json files a valid resource. Could also be added to assetlib if it doesnt already exist.

As a follow question, may I ask what you are using these json files for exactly?

Thought: files whose extension matches a custom resource type defined in the export settings should be displayed in the file dock, even if there is no means of opening them within godot.

I can't find this list extensions for additional files for resource packs feature. But anyway, it's beside the point. The point is that you can have a game that happily works in the development environment, but fails when you deploy it. The feature is a debug warning when your code accesses a resource file that is not listed in the FileSystem. This would help developers who are not aware there is a problem, just like the warnings for Integer Division, etc.

As for my the source of JSON files as resources, my VR godot code is here: https://github.com/goatchurchprime/tunnelvr and I am using the scripts for encoding the cave passage shapes into JSON that are required for this AR app written in Javascript and WebGL https://github.com/CaveSurveying/cavegroundwindow

Another reasonable source of JSON files is if you've followed the save game tutorial and saved the game state in a JSON file. https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html Then for demo purposes you may want to automatically start up with a previously saved game state, and would therefore copy that JSON file from the user area into the game resources for distribution.

Json files are not recognized as resources. They're external files you happen to be putting into the project folder.

My suggestion would let file extensions specified in the export settings be recognized as resources in the file dock. Displaying them to you as part of the project.

Also, this feature, which is right here
image

solves you actual problem at hand anyways. This is the thing thats responsible for exporting them as part of your project.

Sidenote: that savegame tutorial is horrendously out of date. JSON files are __not__ recommended for savegames.

Sidenote: that savegame tutorial is horrendously out of date. JSON files are not recommended for savegames.

Would please mind providing a better reference about how to save data? I know I read somewhere in the docs a discussion about JSON vs an "own" format, but I cannot find it now... I'm specifically interested in saving and loading the content of a GraphEdit (children, zoom, grid size...).

ConfigFile, while primarily intended to be used for configuration files, can also be used for save games as it can serialize any Godot datatype (except custom objects). Unlike JSON, you don't need to manually serialize/deserialize complex types such as Vector2 or Vector3.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SleepProgger picture SleepProgger  路  3Comments

Dorifor picture Dorifor  路  3Comments

lupoDharkael picture lupoDharkael  路  3Comments

regakakobigman picture regakakobigman  路  3Comments

KoBeWi picture KoBeWi  路  3Comments