Namespace Saver

Module used to save data between world sessions, different worlds have their own saves.

Functions

  • 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.

    Parameters

    Returns void

    let thirst = 20;
    Saver.addSavesScope("thirst_library.thirst",
    function read(scope) {
    thirst = scope ? scope.thirst : 20;
    },
    function save() {
    return { thirst: thirst };
    }
    );
  • Registers object as object instance saver.

    Parameters

    • name: string

      saves scope name

    • saver: IObjectSaver

      object that implements Saver.IObjectSaver interface and can be loaded and saved via it's functions calls

    Returns number

    Saver identifier of your object instance.

    function PedestalTile(type) {
    this.type = type;
    Saver.registerObject(this, PedestalTile.saverId);
    }
    PedestalTile.saverId = Saver.registerObjectSaver("mystical_agriculture.pedestal", {
    read(obj) {
    return new PedestalTile(obj.type);
    },
    save(instance) {
    return { type: instance.type };
    }
    });
  • Registers object as scope saver.

    Parameters

    • name: string

      saves scope name

    • saver: IScopeSaver

      object that implements Saver.IScopeSaver interface and can be loaded and saved via it's functions calls

    Returns void

  • Changes registered via Saver.registerObject instance behavior to object be skippable or not.

    Parameters

    • obj: object

      target object instance

    • ignore: boolean

      should be skipped on saving

    Returns void

Type Aliases

SaveableObjectType: object | org.json.JSONObject | IHashSaver

Copyright © 2024 Nernar. Copyright © 2020 #mineprogramming. Built with ❤ and TypeDoc.