Saving Problem And Other Question

Non-platform specific questions.

Saving Problem And Other Question

Postby knucklecrunchgames » Fri Jan 03, 2014 5:29 pm

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. :)
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Saving Problem And Other Question

Postby MrJolteon » Fri Jan 03, 2014 6:20 pm

knucklecrunchgames wrote:And has makslane made any games?

Yes.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Saving Problem And Other Question

Postby knucklecrunchgames » Fri Jan 03, 2014 6:34 pm

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 :)
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Saving Problem And Other Question

Postby knucklecrunchgames » Fri Jan 03, 2014 6:35 pm

MrJolteon wrote:
knucklecrunchgames wrote:And has makslane made any games?

Yes.


Thanks Jolteon +1
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Saving Problem And Other Question

Postby knucklecrunchgames » Sat Jan 04, 2014 12:56 am

Anyone able to answer my other questions :(
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Saving Problem And Other Question

Postby MrJolteon » Sat Jan 04, 2014 7:28 am

Be patient.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: Saving Problem And Other Question

Postby lcl » Sat Jan 04, 2014 10:07 pm

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.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Saving Problem And Other Question

Postby knucklecrunchgames » Sun Jan 05, 2014 12:50 pm

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.
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Saving Problem And Other Question

Postby lcl » Sun Jan 05, 2014 4:41 pm

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. :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Saving Problem And Other Question

Postby knucklecrunchgames » Sun Jan 05, 2014 4:44 pm

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
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Saving Problem And Other Question

Postby lcl » Sun Jan 05, 2014 4:56 pm

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).
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Saving Problem And Other Question

Postby knucklecrunchgames » Sun Jan 05, 2014 5:01 pm

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
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Saving Problem And Other Question

Postby lcl » Sun Jan 05, 2014 5:06 pm

knucklecrunchgames wrote:Man you are great thankyou lcl +1 again tomorrow

No problem :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Saving Problem And Other Question

Postby knucklecrunchgames » Sun Jan 05, 2014 5:24 pm

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
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Saving Problem And Other Question

Postby lcl » Sun Jan 05, 2014 5:39 pm

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.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron