0 votes

Hello!

I've noticed that in the game Minecraft, there are many .json files inside that each specify a single thing (e.g. there is a file for every advancement). Now, I know Java and GDScript are both very different things, but I am still puzzled by one question that I feel still stands in GDScript.

Why not just make variables for each of these, instead of files, inside a script?

Basically, what I am asking is if it is a good idea to use this practice in Godot.

Thanks!

Godot version 3.4
in Engine by (75 points)

1 Answer

+2 votes
Best answer

Files are used for storing the program's state, as well as bits of data. A program may have to read from a file, or write to it, to store information for later. A program will store values and variables in RAM (or similar media) when it runs. While a program can use files for storing data and its state when it's running (some Unix-like OSes do that for certain processes), this may slow down the process, as the program is using some storage medium (e.g. a hard drive or an SSD). Usually, the storage medium is slower than using RAM. As such, the program will use a file when storing something for later. When the program needs to keep data available (and quickly access the data), it will use RAM.

Hope that answers your question.

by (3,112 points)
selected by
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.