Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Saver

Module used to save data between world sessions

Index

Type aliases

LoadScopeFunc

LoadScopeFunc: (scope: object | null) => void

Function that loads data from scope

Type declaration

    • (scope: object | null): void
    • Parameters

      • scope: object | null

        data

      Returns void

SaveScopeFunc

SaveScopeFunc: () => object

Function that returns object representing created scope. No primitives are allowed as return value

Type declaration

    • (): object
    • Returns object

      saved data

Functions

addSavesScope

  • Creates saves scope, a universal data storage container. This storage container should be used whenever you need to save some data between world sessions. If you want to store primitives, use an object to wrap them

    Example:

    var thirst = 20;
    Saver.addSavesScope("thirst",
        function read(scope){
            thirst = scope? scope.thirst: 20;
        },
    
        function save(){
            return {"value": thirst};
        }
    );

    Parameters

    • name: string

      saves scope name

    • loadFunc: LoadScopeFunc

      function used to load saved data

    • saveFunc: SaveScopeFunc

      function used to save data

    Returns void

registerObject

  • registerObject(obj: any, saverId: any): void

registerObjectSaver

  • registerObjectSaver(name: string, saver: any): void

registerScopeSaver

  • registerScopeSaver(name: string, saver: any): ScopeSaver
  • Registers object as scope saver

    Parameters

    • name: string

      saves scope name

    • saver: any

      object that implements Saver.ScopeSaver interface and can be loaded and saved via its functions calls

    Returns ScopeSaver

setObjectIgnored

  • setObjectIgnored(obj: any, ignore: any): void

Generated using TypeDoc