Saving and Loading

You must understand the Game Editor concepts, before post here.

Re: Saving and Loading

Postby GuybrushThreepwood » Fri Oct 17, 2008 10:16 am

I dont get it... could someone make a tutorial please? :mrgreen:
Pirate: You fight like a diary farmer!
Guybrush: How appropriate, you fight like a cow!
User avatar
GuybrushThreepwood
 
Posts: 94
Joined: Sun Jul 06, 2008 12:23 pm
Location: Melee Island
Score: 2 Give a positive score

Re: Saving and Loading

Postby Bee-Ant » Fri Oct 17, 2008 11:47 am

GE already has a built in tutorial about this. "Updating SCORE" or something...
This is what I mean with hard to explain... :roll:
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Saving and Loading

Postby j2graves » Sat Oct 25, 2008 1:19 am

I only know the global integer one =(
No games to my name...
User avatar
j2graves
 
Posts: 1302
Joined: Thu Aug 16, 2007 6:42 pm
Location: on the other side of infinity
Score: 19 Give a positive score

Re: Saving and Loading

Postby Kalladdolf » Sat Oct 25, 2008 9:05 am

lol, I'm sorry to say that, but I read this post for the first time. As I scrolled down I more and more became like :roll: .
:wink:
Never mind that now, lemme explain:
There are global variables (which apply to all actors in the game)
and actor variables (which only apply to only one actor)
Example for global variable: You set a gravity which can change during the game. But you'd like every actor to obey its force.
Example for actor variable: Your hero finds himself in front of a bunch of hideous enemies. He starts killing them. Everyone has a certain health. But the "actor variable" has the advantage that you don't have to create a new health variable for each individual clone, but only one variable for everyone. If you shoot him only his health goes down and he dies. With a global variable, every enemy would've died when you killed only one! That's kinda funny (give or take a little) but it doesn't serve the purpose.

So much for the variables.
If you want script examples, just ask for 'em.

Now, let's turn our attention to the saving/loading.
In this case, we want to save the level we're in.
First create a global variable called "level" and the save group called "data" (this is important!) and the level variable gets higher every time you complete a level.
Collision -> goal ->
Code: Select all
level = level + 1;

Still with me? good.
Now add a saving button.
Add the event "mouse button down (left)" and select the Script Editor as action.
Then (if you're not familiar with the scripting) open the variable-and-function panel.
You'll find a variety of stuff you can select there (including your own level variable which you should be proud of :wink: ).
Select the SaveVars function. A window will appear asking for the variable, the group and the file it should be saved in.
Now you can decide what to enter. Call the file whatever you want, just MAKE SURE that it's exactly the same file when you LOAD the variables. Select the "data" save group which you've created previously along with your level variable (if you still remember XD). Groups are there for your variables in order not to get messed up. Once you completed that step, click "ok". The code should basically look like that:
Code: Select all
saveVars("data", "data");


That's done it! You've saved your level! (This is a very simple way, believe it or not).

Now to the loading:

Create a load button
MouseButton down -> LoadButton
Code: Select all
loadVars("data", "data");


And now you've loaded the level variable.
From there, you can let your actor take certain actions depending on the level variable, such as changing his position if the level equals a certain number.

I hope that helped.
-K@ll
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Saving and Loading

Postby BlarghNRawr » Sat Oct 25, 2008 8:34 pm

hey thanks :D :lol:
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: Saving and Loading

Postby Kalladdolf » Sat Nov 08, 2008 7:33 pm

well, GT, is that what you had in mind?
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: Saving and Loading

Postby GuybrushThreepwood » Sat Nov 08, 2008 9:58 pm

Collision -> goal ->
Code: Select all
level = level + 1;



Were does that go? :mrgreen:
Pirate: You fight like a diary farmer!
Guybrush: How appropriate, you fight like a cow!
User avatar
GuybrushThreepwood
 
Posts: 94
Joined: Sun Jul 06, 2008 12:23 pm
Location: Melee Island
Score: 2 Give a positive score

Re: Saving and Loading

Postby BlarghNRawr » Sun Nov 09, 2008 3:29 am

on collision with goal
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: Saving and Loading

Postby DilloDude » Sun Nov 09, 2008 5:05 am

Or whatever event finishes the level.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Saving and Loading

Postby GuybrushThreepwood » Sun Nov 09, 2008 6:13 am

see Kalladdolf, i dont have levels, its a point an click/puzzle/adventure game (probably should of mentioned that earlier :mrgreen: )
Pirate: You fight like a diary farmer!
Guybrush: How appropriate, you fight like a cow!
User avatar
GuybrushThreepwood
 
Posts: 94
Joined: Sun Jul 06, 2008 12:23 pm
Location: Melee Island
Score: 2 Give a positive score

Re: Saving and Loading

Postby DilloDude » Sun Nov 09, 2008 7:51 am

Exactly. This basic example deals with the situation where you just need to save which level you're up to. In a more complicated example, you will need to save a lot more things, such as inventory, which things have been collected (if there's only 1 of something, and you have it, you don't want it to still be there), which places you have visited, where you are now, what goals you have achieved etc. But the basic process is the same: create variables to store everything, put them in a save group; when things happen, update the variabes; when you save, save the group; when you load, load the group and set stuff up according to those variables.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Previous

Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest