Page 1 of 2

Saving to load a dat

PostPosted: Sun Jan 12, 2014 5:44 pm
by knucklecrunchgames
Hello everyone. I wanted to ask a question to finally finish my game

How do I load the dat that the player has saved from another dat.

Example: On mainmenu.dat you press new game, you play and you turn off for now. When you turn on you press load game and you load on the dat you saved on.

How could I do this?

And thankyou for everything everyone :) :) :)

Re: Saving to load a dat

PostPosted: Sun Jan 12, 2014 8:21 pm
by Goettsch
you already made this question and lcl already asked it,it is impossible to do what you want
viewtopic.php?f=2&t=13134

Re: Saving to load a dat

PostPosted: Sun Jan 12, 2014 9:52 pm
by knucklecrunchgames
Goettsch wrote:you already made this question and lcl already asked it,it is impossible to do what you want
viewtopic.php?f=2&t=13134


Goettsch If your so quick to reply lecturing me then explain how you do it. :evil:

Re: Saving to load a dat

PostPosted: Sun Jan 12, 2014 10:18 pm
by skydereign
knucklecrunchgames wrote:Goettsch If your so quick to reply lecturing me then explain how you do it. :evil:

All Goettsch is saying is If you already asked a question don't create another topic about it. It is okay to bump the other topic if you didn't get the answer you wanted. That being said if I understand your question, I don't think this is exactly a repeat (though I feel you should have posted it on the other topic). To answer your question you would have one save file (created via saveVars). In addition to saving the player's position, you also need to save which level file they are in. That means every time they transition to a new level file (the new .dat) you must save the name of that .dat, that way in the menu when you want to load a save file you can use LoadGame on that saved file name.

Re: Saving to load a dat

PostPosted: Sun Jan 12, 2014 10:43 pm
by knucklecrunchgames
skydereign wrote:
knucklecrunchgames wrote:Goettsch If your so quick to reply lecturing me then explain how you do it. :evil:

All Goettsch is saying is If you already asked a question don't create another topic about it. It is okay to bump the other topic if you didn't get the answer you wanted. That being said if I understand your question, I don't think this is exactly a repeat (though I feel you should have posted it on the other topic). To answer your question you would have one save file (created via saveVars). In addition to saving the player's position, you also need to save which level file they are in. That means every time they transition to a new level file (the new .dat) you must save the name of that .dat, that way in the menu when you want to load a save file you can use LoadGame on that saved file name.



I think I half understand it, but can you make it a bit more simple for me to understand,

thankyou for your time

Re: Saving to load a dat

PostPosted: Sun Jan 12, 2014 10:53 pm
by skydereign
knucklecrunchgames wrote:I think I half understand it, but can you make it a bit more simple for me to understand,

You understand how to save the player's position in a single .dat file already. All you do is save the variables, that way when you load up the dat file you can load the saved variables and update the player's position to the correct spot.

Now that you have multiple .dat files for the multiple levels, you need to also remember which level file the player is in. To do this you can have one more variable that you keep track while saving and loading. This variable holds the name of the .dat file the player is currently in.

The player starts a new game. As the game loads it saves the name of the file into your save file. If the player wants to take a break, they exit the game and you save their position within the level. Now the player starts the game and selects load game. In the menu it loads the save file and now has the name of the file it needs to load, and calls LoadGame on it. The player then beats the level and moves onto the next one. Just like with level one when the player enters the level it saves the name of the current level file into your save file. That's it.

Re: Saving to load a dat

PostPosted: Mon Jan 13, 2014 3:58 pm
by knucklecrunchgames
skydereign wrote:
knucklecrunchgames wrote:I think I half understand it, but can you make it a bit more simple for me to understand,

You understand how to save the player's position in a single .dat file already. All you do is save the variables, that way when you load up the dat file you can load the saved variables and update the player's position to the correct spot.

Now that you have multiple .dat files for the multiple levels, you need to also remember which level file the player is in. To do this you can have one more variable that you keep track while saving and loading. This variable holds the name of the .dat file the player is currently in.

The player starts a new game. As the game loads it saves the name of the file into your save file. If the player wants to take a break, they exit the game and you save their position within the level. Now the player starts the game and selects load game. In the menu it loads the save file and now has the name of the file it needs to load, and calls LoadGame on it. The player then beats the level and moves onto the next one. Just like with level one when the player enters the level it saves the name of the current level file into your save file. That's it.


I'm so sorry to waste your time sky, but I still don't understand it.

Where and what codes do I put in, Again, so sorry for wasting your time :(

Re: Saving to load a dat

PostPosted: Mon Jan 13, 2014 4:06 pm
by skydereign
knucklecrunchgames wrote:I'm so sorry to waste your time sky, but I still don't understand it.

Where and what codes do I put in, Again, so sorry for wasting your time :(

What part don't you understand? The idea is almost exactly like saving the player's position in a file (something that you said you did understand). The only difference is to create one more variable that holds what game file the player is in.

Re: Saving to load a dat

PostPosted: Mon Jan 13, 2014 4:23 pm
by knucklecrunchgames
skydereign wrote:
knucklecrunchgames wrote:I'm so sorry to waste your time sky, but I still don't understand it.

Where and what codes do I put in, Again, so sorry for wasting your time :(

What part don't you understand? The idea is almost exactly like saving the player's position in a file (something that you said you did understand). The only difference is to create one more variable that holds what game file the player is in.


I know how to make the variable that holds the position, but What I don't know what code I would use to hold what game file the player is in. I there any ged that explains it or tutorial.

Thankyou for putting up with me. :)

Re: Saving to load a dat

PostPosted: Mon Jan 13, 2014 4:44 pm
by skydereign
knucklecrunchgames wrote:I there any ged that explains it or tutorial.

No, because all it takes is one line. Do you know anything about strings?

Re: Saving to load a dat

PostPosted: Mon Jan 13, 2014 4:54 pm
by knucklecrunchgames
skydereign wrote:
knucklecrunchgames wrote:I there any ged that explains it or tutorial.

No, because all it takes is one line. Do you know anything about strings?


no. what do strings do? :?: :?:

Re: Saving to load a dat

PostPosted: Mon Jan 13, 2014 6:14 pm
by skydereign
Please do not bump topics until at least a day has passed since the last post. Have a little patience, we can't always answer immediately.
knucklecrunchgames wrote:no. what do strings do? :?: :?:

Strings store text. You can create them the same way you create other variables for saving. For what you need (saving the name of the file) you just do this.
Code: Select all
strcpy(string_variable, "nameoffile.dat");
// now saveVars will save string_variable into the save file

Re: Saving to load a dat

PostPosted: Mon Jan 13, 2014 6:34 pm
by knucklecrunchgames
// now saveVars will save string_variable into the save file


Does this mean when you press load game it will load the dat the player saved on?

Re: Saving to load a dat

PostPosted: Mon Jan 13, 2014 6:39 pm
by skydereign
knucklecrunchgames wrote:Does this mean when you press load game it will load the dat the player saved on?

Think about it. When you call LoadGame you pass in a string holding the file name of the file you want to load. I told you how to store a string into a variable so that you can save it. To access that variable so you can use it for LoadGame, you'll have to call loadVars. You should reread my posts and see if you understand what I was telling you now.

Re: Saving to load a dat

PostPosted: Mon Jan 13, 2014 6:42 pm
by knucklecrunchgames
skydereign wrote:
knucklecrunchgames wrote:Does this mean when you press load game it will load the dat the player saved on?

Think about it. When you call LoadGame you pass in a string holding the file name of the file you want to load. I told you how to store a string into a variable so that you can save it. To access that variable so you can use it for LoadGame, you'll have to call loadVars. You should reread my posts and see if you understand what I was telling you now.


when I put this code in an error comes up. What do I put it in?

load game or level 1, level 2 ect