Saverestore

From GMod Wiki

Jump to: navigation, search

This module is to help bind the engine's saverestore stuff to Lua. This is so we can save Lua stuff in the save game file. The entities should automatically save most of their table contents to the save file.

You can hook into this system like so:

 
	local function MySaveFunction( save )
		saverestore.WriteTable( my_table, save )
	end
 
	local function MyRestoreFunction( restore )
		my_table = saverestore.ReadTable( restore )
	end
 
	saverestore.AddSaveHook( "HookNameHere", MySaveFunction )
	saverestore.AddRestoreHook( "HookNameHere", MyRestoreFunction )
 

This will then save/load everything in my_table when the game is saved/loaded.

Library Functions

NewerShared.png saverestore.AddRestoreHook
NewerShared.png saverestore.AddSaveHook
NewerShared.png saverestore.LoadEntity
NewerShared.png saverestore.LoadGlobal
NewerShared.png saverestore.PreRestore
NewerShared.png saverestore.PreSave
NewerShared.png saverestore.ReadTable
NewerShared.png saverestore.ReadVar
NewerShared.png saverestore.SaveEntity
NewerShared.png saverestore.SaveGlobal
NewerShared.png saverestore.WritableKeysInTable
NewerShared.png saverestore.WriteTable
NewerShared.png saverestore.WriteVar

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox