Saverestore
From GMod Wiki
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
saverestore.AddRestoreHook
saverestore.AddSaveHook
saverestore.LoadEntity
saverestore.LoadGlobal
saverestore.PreRestore
saverestore.PreSave
saverestore.ReadTable
saverestore.ReadVar
saverestore.SaveEntity
saverestore.SaveGlobal
saverestore.WritableKeysInTable
saverestore.WriteTable
saverestore.WriteVar