Page 1 of 2

Saving Problem And Other Question

PostPosted: Fri Jan 03, 2014 5:29 pm
by knucklecrunchgames
OK. On my game You press new game play the game and then you get tired of playing. How do I save it to load the dat file it was saved on.

next question Did anyone remove my post, It was a joystick question

And has makslane made any games?

Please reply. Thanks

Knuckle Crunch Games

Oh I forgot, Happy new year everyone. :)

Re: Saving Problem And Other Question

PostPosted: Fri Jan 03, 2014 6:20 pm
by MrJolteon
knucklecrunchgames wrote:And has makslane made any games?

Yes.

Re: Saving Problem And Other Question

PostPosted: Fri Jan 03, 2014 6:34 pm
by knucklecrunchgames
Oh and another question, how do I make a store.

for example I collect lots of coins on level 1

I save and go to the store and my coins I collected are there and I buy powerups and the coins I have are taken away :)

Re: Saving Problem And Other Question

PostPosted: Fri Jan 03, 2014 6:35 pm
by knucklecrunchgames
MrJolteon wrote:
knucklecrunchgames wrote:And has makslane made any games?

Yes.


Thanks Jolteon +1

Re: Saving Problem And Other Question

PostPosted: Sat Jan 04, 2014 12:56 am
by knucklecrunchgames
Anyone able to answer my other questions :(

Re: Saving Problem And Other Question

PostPosted: Sat Jan 04, 2014 7:28 am
by MrJolteon
Be patient.

Re: Saving Problem And Other Question

PostPosted: Sat Jan 04, 2014 10:07 pm
by lcl
knucklecrunchgames wrote:OK. On my game You press new game play the game and then you get tired of playing. How do I save it to load the dat file it was saved on

Basically all you need is to have variables with a save group for all the things you want to save, player position, view position, score, etc.
and then you use saveVars() to save them, and when loadVars() to load them.

Re: Saving Problem And Other Question

PostPosted: Sun Jan 05, 2014 12:50 pm
by knucklecrunchgames
lcl wrote:
knucklecrunchgames wrote:OK. On my game You press new game play the game and then you get tired of playing. How do I save it to load the dat file it was saved on

Basically all you need is to have variables with a save group for all the things you want to save, player position, view position, score, etc.
and then you use saveVars() to save them, and when loadVars() to load them.


Thankyou LCL But what code would I use to save the players position.

Re: Saving Problem And Other Question

PostPosted: Sun Jan 05, 2014 4:41 pm
by lcl
Using saveVars and loadVars has been explained very many times on this forum.
You should try to find out by yourself before asking questions, because there really is answers to most of the simpler questions people have.

I'll explain it to you now shortly.
You know what variables are, right?

So, for saving the player actors position (values of x and y), you have to first create two global integer variables with a save group.
You can name the save group whatever you want, an example would be playerPosition.

Then, you write this code to the script editor event where you want to save the game:
Code: Select all
posX = player.x;
posY = player.y;
saveVars("gamesaves.sav", "playerPosition");

The position will be saved to a file named gamesaves.sav.
This code is all you need for saving the player position provided that your variables are named posX and posY, and that they belong to a save group named playerPosition, and that your main actor is called player.

Then when you want to load the values, and set the player actor back to the saved position, you just have to write this:
Code: Select all
loadVars("gamesaves.sav", "playerPosition");
player.x = posX;
player.y = posY;


This is all you need for saving and loading an actors coordinates.
I hope that you think through the code, because just copying it to your game won't help you learn anything, because learning code is possible only after understanding it.

If you don't understand the code, say it, and I'll explain it to you bit by bit so that you will understand and learn it. :)

Re: Saving Problem And Other Question

PostPosted: Sun Jan 05, 2014 4:44 pm
by knucklecrunchgames
lcl wrote:Using saveVars and loadVars has been explained very many times on this forum.
You should try to find out by yourself before asking questions, because there really is answers to most of the simpler questions people have.

I'll explain it to you now shortly.
You know what variables are, right?

So, for saving the player actors position (values of x and y), you have to first create two global integer variables with a save group.
You can name the save group whatever you want, an example would be playerPosition.

Then, you write this code to the script editor event where you want to save the game:
Code: Select all
posX = player.x;
posY = player.y;
saveVars("gamesaves.sav", "playerPosition");

The position will be saved to a file named gamesaves.sav.
This code is all you need for saving the player position provided that your variables are named posX and posY, and that they belong to a save group named playerPosition, and that your main actor is called player.

Then when you want to load the values, and set the player actor back to the saved position, you just have to write this:
Code: Select all
loadVars("gamesaves.sav", "playerPosition");
player.x = posX;
player.y = posY;


This is all you need for saving and loading an actors coordinates.
I hope that you think through the code, because just copying it to your game won't help you learn anything, because learning code is possible only after understanding it.

If you don't understand the code, say it, and I'll explain it to you bit by bit so that you will understand and learn it. :)


Thankyou LCL I understand perfectly. if I could +200 but I can only give +1 a day :)

Is there a tutorial or post full of what varibals can do

Re: Saving Problem And Other Question

PostPosted: Sun Jan 05, 2014 4:56 pm
by lcl
Basically variables are named numbers. You can give them any values you want, only depending on their type.
Integer variables can only have integer values, and double and float variables can have real numbers, e.g. floating point values.

Read more from here: viewtopic.php?f=27&t=6834&p=48846&hilit=keywords+and+functions#p48846
The whole post is quite useful, but for understanding variables, you should read at least the explanation under these subheads:
-double
-int
-operators
and I also recommend reading about if condition (it's just above the 'operators' subhead).

Re: Saving Problem And Other Question

PostPosted: Sun Jan 05, 2014 5:01 pm
by knucklecrunchgames
lcl wrote:Basically variables are named numbers. You can give them any values you want, only depending on their type.
Integer variables can only have integer values, and double and float variables can have real numbers, e.g. floating point values.

Read more from here: viewtopic.php?f=27&t=6834&p=48846&hilit=keywords+and+functions#p48846
The whole post is quite useful, but for understanding variables, you should read at least the explanation under these subheads:
-double
-int
-operators
and I also recommend reading about if condition (it's just above the 'operators' subhead).


Man you are great thankyou lcl +1 again tomorrow

Re: Saving Problem And Other Question

PostPosted: Sun Jan 05, 2014 5:06 pm
by lcl
knucklecrunchgames wrote:Man you are great thankyou lcl +1 again tomorrow

No problem :D

Re: Saving Problem And Other Question

PostPosted: Sun Jan 05, 2014 5:24 pm
by knucklecrunchgames
Just another question

Is there a way to convert a dat into a save file

example you play my game (Example name: magic level player)
there is no levels

you launch magic level creator and make a level

you export the level you made and it is called levelmade.save

magic level player loads levelmade.save and the level you made is there.

I swear all this answering will pay off in an awesome fun game :D

Re: Saving Problem And Other Question

PostPosted: Sun Jan 05, 2014 5:39 pm
by lcl
If with .dat file you mean a level made in game editor and saved as .dat, then no, you can't convert it into a save file.
You can rename the file, but you can't open it with loadVars(), you would have to use LoadGame();

But however, you could use game editor to make a simple level editor, which just allows you to place objects around.
Then all you'd need to do would be to save the objects' positions to a single file and then use loadVars() to get those positions from that file
and build the level by that information by creating the correct actors to correct positions.