Page 1 of 2

How to save Variable in a Native Game?

PostPosted: Mon 5 Nov 2018, 16:51
by Game Developer
I am making a HighScore game so that's why I need to know how to save variables in Native Games. I already saw some tutorials and followed it but it never worked but when I tried it on a WebGL Game the score just saved and loaded successfully!
So in Native Game the HighScore successfully saves in an XML file but it can't be loaded again in the Game.
I think that when I save it multiple times and edit the XML file with Notepad, I can see multiple Groups with same name that's why the Variable not loading...
Please help me to save and load variables successfully. If you can give me a example, that would be so good!
Note: If you are creating the example please use version 3 because I have 32-bit window so can't install GDevelop 5 :P

Re: How to save Variable in a Native Game?

PostPosted: Mon 5 Nov 2018, 19:57
by Lizard-13
Wow, version 3 !?, GD 4 has support for 32 bits, and you can compile GD 5 yourself to get a 32 bit version ;)

Check if the group you're using start with a number, the bug was discovered here: http://forum.compilgames.net/viewtopic.php?f=19&t=9876
And reported here: https://github.com/4ian/GDevelop/issues/479
But no solution so far, and probably there won't be, as GD 4 is being discontinued :(

Re: How to save Variable in a Native Game?

PostPosted: Wed 7 Nov 2018, 18:57
by Game Developer
How to compile GD 5 for 32-Bit??? But anyways I am using version 3 because 4 just freezes when I open "Scene Editor".
The group is named as "1". Everyone names it like this! And it works for WebGL games and not for Native Games. Why???
I created a new project for WebGL and Copied the exact scene and pasted it on the WebGL game... Then how's this possible... I think that it can't load the file easily and it creates more than 1 groups with the same name,"1". :? :? :?

Re: How to save Variable in a Native Game?

PostPosted: Wed 7 Nov 2018, 23:06
by Lizard-13
If you follow the link to the GitHub issue you'll see that we suspect it's a problem from the XML parser, it does not affect web games because JSON is used instead XML.

Note that groups names are dynamic strings, if you name your groups “g1", "g2", "g3", etc instead "1", "2", "3" you can access them as easy as before, if right now you're doing something like:
Code: Select allToString(Variable(group_index))

you can do:
Code: Select all"g" + ToString(Variable(group_index))

And as "gN" groups don't start with a number you won't face the bug :)

Re: How to save Variable in a Native Game?

PostPosted: Mon 12 Nov 2018, 19:21
by Game Developer
Can you please give me an example file??? :( :( :(
I am still facing the issue...

Re: How to save Variable in a Native Game?

PostPosted: Mon 12 Nov 2018, 23:53
by Lizard-13
How are your events?

Re: How to save Variable in a Native Game?

PostPosted: Thu 15 Nov 2018, 18:36
by Game Developer
Hmm... OK I will soon give a google drive link for the example and an image of the events... :) :) :)

Re: How to save Variable in a Native Game?

PostPosted: Wed 21 Nov 2018, 11:12
by Game Developer
Here is the example:
Texte caché : cliquez sur le cadre pour l'afficher

https://drive.google.com/open?id=13H477-j6Acg0ti-uJDeteH1Ss1YdGVhB

Please help as soon as possible!!! :P

Re: How to save Variable in a Native Game?

PostPosted: Thu 22 Nov 2018, 00:48
by Lizard-13
Here, as I explained just change the group "1" by "g1" (for example, anything that doesn't start with a number works).
Also, it seems that the file must contain an extension, any extension, so I've renamed the file "Highscore" as "Highscore.sav", you can use "Highscore.txt" to be able to open easily with a plain text editor :)

Re: How to save Variable in a Native Game?

PostPosted: Wed 28 Nov 2018, 14:33
by Game Developer
Sorry! The file you uploaded doens't load. It says something like:"The file is created in too old version of gdevelop. Please use Gdevelop 2 to open it"
Can you create it for Gdevelop 3?