SLUDGE

saveGame


Syntax:

saveGame (text);

Purpose:

Creates a file with the name text which contains the current state of the SLUDGE engine. The text value must be a string not a file handle for this command to work as expected! The loadGame command can then be used to load in one of these files to return the engine to exactly the same state.

Any run-time files which your SLUDGE game uses (i.e. any custom data or saved game files) will be created in (and loaded from) the application data folder of the game. (Documents and Settings/username/Application Data/Game Name on Windows, $HOME/.sludge-engine/Game Name on Linux and ~/Application Support/Game Name on Mac). See also .

Your saved game files, as well as containing all the information needed to restore a player's progress at any time, can also (optionally) contain a thumbnail image. The size of the image generated and saved can be set using setThumbnailSize.

Currently, games cannot be saved while anything is frozen (using the freeze command).

Note that when the loadGame command is called successfully and the engine returns to its state when the file was created, execution will restart after the call to saveGame, not after the call to loadGame. This is because everything - including the function which called the saveGame command - is saved to the file and therefore restored when loadGame is called. You can tell whether you've just loaded or saved a game by looking at the return value.

This function supports filename bodging - for details see the bodgeFilenames command.

Return value:

Returns TRUE if the state of the engine was just saved. Returns FALSE if the game has just restarted at this point after a call to loadGame.

See also:

The World's Easiest Load/Save Mechanism

deleteFile

fileExists

getMatchingFiles

loadCustomData and saveCustomData

renameFile

showThumbnail