save var
Posted: Fri Apr 08, 2011 4:31 pm
Hi
I put the variables are stored, are stored in a folder. To do this, what should I do?
I put the variables are stored, are stored in a folder. To do this, what should I do?
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!