Save/Load a global variable in a file

For questions about using Classic.

Post » Fri Jul 20, 2012 1:23 pm

Hello,
I'm Spanish, I'm using the google translator. My English is bad.
I have a question:
How I can save a global variable in a file and then load it?
B
3
Posts: 36
Reputation: 347

Post » Fri Jul 20, 2012 10:38 pm

You can use INI files to do this quickly:

INI level loadingJayjay2012-07-20 22:38:32
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Fri Jul 20, 2012 11:25 pm

Yep, .ini is the best way to go. But I wonder what ever happened to the development of the save/load action? Or Quicksave/Quickload?MrMiller2012-07-20 23:26:22
B
12
S
4
G
3
Posts: 426
Reputation: 2,458

Post » Sat Jul 21, 2012 6:29 pm

The save/load actions work, they should save the entire state of the game. The shortcoming of it is not all the plugins save/load all of their state.
B
79
S
24
G
54
Posts: 4,749
Reputation: 40,761

Post » Sun Dec 09, 2012 10:00 pm

Sorry to necro this thread, but I'm looking for a similar solution.

The save/load to disk command does not save the state of global variables, and one of the global variables I'm using saves the player's high score (so that he can always compare his latest score to his highest).

Now I could simply save the high score data to an ini file and have the game read from that, but then the player can always just open that ini file and type "9999999999999999999999999999999999" into the high score section.

Is there another way around this, or is it just one of Construct Classic's (few and far between) flaws that I'll have to live with?
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Mon Dec 10, 2012 11:18 am

@-Silver- Try using binary storage plugin (works pretty similar to INI) for things you don't want the player to edit, and also save your file with a custom extension (eg: .gsv) so it doesn't stand out as INI or txt
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Mon Dec 10, 2012 1:25 pm

Do you mean the Binary object that comes with the engine? Found under "Data and Files"? Because a quick search around the forums suggests it's broken - you can write to it once, but that's it. Further writing just adds to the existing text, instead of replacing it, and deleting/clearing existing text doesn't work.

So if the player gets a high score of 1234, I can write that, and then read it just fine. But if they then beat it with a high score of 5678 and I try writing that, the high score will now read as 12345678 instead of 5678.
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Wed Aug 14, 2013 3:47 pm

Hey,

I also have the same problem. I have a globale varibale called "globale_score". After every time the player die, the value of the "score" variable will be writen into the "globale_score" variable. But allways the game will be closed, the "globale_score" lose his value. How can i save this value in the easiest way?

Thanks a lot!
Image Image
The Apple logo, iPhone, iPod touch, and iTunes are trademarks of Apple Inc., registered in the U.S. and other countries.
B
69
S
23
G
21
Posts: 906
Reputation: 20,762


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests