Saveing

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

Saveing

Postby MonteyPython » Wed Jun 03, 2009 2:55 am

Can anyone tell me how to save everything in my game? I've looked at other posts, but none of them seem to work for me. Can anyone help?
MonteyPython
 
Posts: 24
Joined: Tue Apr 21, 2009 6:15 pm
Score: 0 Give a positive score

Re: Saveing

Postby skydereign » Wed Jun 03, 2009 5:49 am

One of those demo/help topics should work... The important part is to make sure your variables are in save groups and to follow the directions of the function. What the save does, is save it into files, under a certain name. That file would then be loaded, load vars. Needing help wasn't that specific so this is the best I can do right now, if you still need help, I can make a more specific demo to fit your needs, though I doubt that that will be necessary.

This is from http://game-editor.com/docs/script_reference.htm
Save functions
Use saveVars and loadVars to save and load any variables in a game, like highscores, current lives, etc. To use these functions, you must use the "Save group" field in the "Add New Variable" panel (Variable button in the Script Editor).
saveVars: Save all variables in the group to the specified file.
The file will be saved in the game directory.
void saveVars(char *file, char *group)
Use saveVars to save any variables in a game; highscores, current lives, etc.
You must use the "Save group" field in the "Add New Variable"panel (Variable button in the Script Editor).

Script Editor Syntax:
saveVars("game.sav", "High Score");

loadVars: Load all the variables in the group from a specified file.
void loadVars(char *file, char *group)


Script Editor Syntax:
loadVars("game.sav", "High Score");

Example:
1. Create a "score" variable and put it in the "High Score" group.
2. Create two more variables: "lives" and "energy". Put these variables in the "Actor State" group.

When the player dies, use saveVars("game.sav", "High Score"); to save the current player's high score without saving the player's state.
When the user exits the game, use saveVars("game.sav", "Actor State"); to save the current player's state (lives and energy).
Note: different variable groups can be saved in the same file (game.sav).
Finally, use loadVars("game.sav", "High Score"); and loadVars("game.sav", "Actor State"); in the proper script editor area of the game!
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron