Variables in text file

Hey everyone.

I’m making a simple platformer game and I want to use variables for settings.
I’d like to be able to edit the variables in a text document.
Example:

[display]
height=1920
width=1080
fullscreen=1

Is this possible with the JSON stuff?
(I’m kinda new to that, so that’s why I’m asking this.)

Thanks in advance.

Check this for files GDevelop 5
And this for parse JSON to a variable GDevelop 5

1 Like

So, if I follow that, will it work like I said?

Sure you first decide the fields you want to store in the JSON, do the events logic to save and load the JSON data to a variable(Global or Scene), then manipulate the results of the variable like any other variable in GDvevelop.
The saved file could even have any extension like gameData.save or whatever extension you want, that in case you don’t want to save as gameData.json.

Look what I do is this, check the filename is SaveThePrincess.sav but the code inside is JSON.

1 Like

I am actually not familliar with the formatting of this:"{" + ““Line1”:“first line”,” + ““Line2”:“second line”” + “}”
Does it have something to do with a programming language?

That is JSON syntax

1 Like

Wow, that’s a pretty dumb question, LOL.
Thanks for your help!

No problem, if you need any help just ask the community is here for help :slight_smile:

1 Like

Hey, one question.
I’m trying it right now.
But how do I define where and under what name the json file should be saved?
In this example you sent, I don´t see anything about a name.

EDIT: When I export the game, I don’t see a json file either.

When you use Filesystem the JSON file is saved in the user PC, in order to do that you need to set the directory that you want to use for saving the file I do like this. For set up the directory


And this when i collect some item then update the file

And this for load the saved file into a variable

1 Like

Thanks for all the work.
Here you save a variable into a JSON file, in the example you sent, you used parse JSON string.
What is the difference?

Oh yeah and why do you have SaveThePrincess.sav? what does the .sav mean?

.sav is the extension that i use for saved file, intead of use .json, it’s a way to basically hide that really is a json file. you can use any extension you want

1 Like