Garry's Mod Wiki

saverestore

The saverestore library contains functions relating to the singleplayer save system built into the game.

Methods

saverestore.AddRestoreHook( string identifier, function callback )
Adds a restore/load hook for the Half-Life 2 save system.
saverestore.AddSaveHook( string identifier, function callback )
Adds a save hook for the Half-Life 2 save system. You can this to carry data through level transitions in Half-Life 2.
saverestore.LoadEntity( Entity ent, IRestore save )
Loads Entity:GetTable from the save game file that is being loaded and merges it with the given entitys Entity:GetTable.
saverestore.LoadGlobal( IRestore save )
This is used internally - although you're able to use it you probably shouldn't. Called by engine when a save is being loaded. This handles loading gamemode and calls all of the hooks added with saverestore. AddRestoreHook.
saverestore.PreRestore()
This is used internally - although you're able to use it you probably shouldn't. Called by the engine just before saverestore. LoadGlobal is.
saverestore.PreSave()
This is used internally - although you're able to use it you probably shouldn't. Called by the engine just before saverestore. SaveGlobal is.
table saverestore.ReadTable( IRestore save )
Reads a table from the save game file that is being loaded.
any saverestore.ReadVar( IRestore save )
Loads a variable from the save game file that is being loaded. Variables will be read in the save order you have saved them.
saverestore.SaveEntity( Entity ent, ISave save )
Saves entitys Entity:GetTable to the save game file that is being saved.
saverestore.SaveGlobal( ISave save )
This is used internally - although you're able to use it you probably shouldn't. Called by engine when a save is being saved. This handles saving gamemode and calls all of the hooks added with saverestore. AddSaveHook.
number saverestore.WritableKeysInTable( table table )
Returns how many writable keys are in the given table.
saverestore.WriteTable( table table, ISave save )
Write a table to a save game file that is being saved.
saverestore.WriteVar( any value, ISave save )
Writes a variable to the save game file that is being saved.