• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

File system[solved]

W

Wild_West

Guest
I took a break from my platformer game to work on something else for a bit but now I'm back at it and can't understand why my saving/loading setup isn't functioning right.

Specifically this part :

Code:
 if(new_game_file == true)
                  {                
                  //Overwrite saved file 
                  show_message("Starting New Game");
                 
                  file_delete("Game_info.ini");
                 
                  //empty the collected treasures values
                  for(empty = 0; empty < array_length_1d(global.collection); empty ++)
                  {if(global.collection[empty] != 0)
                    global.collection[empty] = 0;}
There'a a lot more that's included but it's just extra values to re initialize / load when I select to load the save data.
Which I haven't really been able to test because I can't get past this first part.
The way my game is setup you have to collect a treasure in each stage to proceed to unlocking the next stage, and there's a global score variable that keeps track of how many of these treasures you have so far.
So for example a treasure value of 1 will unlock stage 2, treasure value of 2 unlocks stage 3 and ect.

This value is supposed to of course reset any time a new game starts but it isn't.
I can tell because I look at the ini file and it says in the treasure section, the first key has a value of 1 already even though I initialize it to zero.
When I load the game save file however, I STILL can't get into stage 2 despite the treasure value variable being 1 already. So I don't know what's going on.

I read about the file system but just couldn't get what they meant by save area vs file directory since I checked my local app data folder and there wasn't any file there.
I put the game save file in that folder, and still no change.

The file is included in my resources tree also.
 
W

Wild_West

Guest
Okay so it turns out that it was my included file that was making it so the game never read the save file as deleted. So I got rid of that one and just kept the file that should be in my app data folder, and now it deletes like it should.
But I still have a problem with my global.collection variable not saving.
Since I saved the information anew in the new save file in the app data folder and literally the ONLY value that should have been there wasn't. The global.collection array.
Why isn't this array saving, when the other ones do?
 
W

Wild_West

Guest
I feel like an idiot but I spotted the problem.
I accidentally named the keys for two different sets of values the same thing.
So I'm guessing my first bunch of values for the treasure collection section of the ini file was getting overwritten by my second.
I've been trying so hard to get a handle on logic I forget all about just checking the basics, like naming lol
 
Top