diff --git a/ModuleApiGameLibRuntimeStorage.md b/ModuleApiGameLibRuntimeStorage.md new file mode 100644 index 0000000..2f57f1f --- /dev/null +++ b/ModuleApiGameLibRuntimeStorage.md @@ -0,0 +1,27 @@ +# ModuleApi - Runtime Storage + +Simple object used to perform time calculations for sychronized rendering across clients. + +## Structure + +```javascript +{ + @readonly "_lastSnapshot": 1754754260809, + @readonly "_keys": [ + "variable1", + "variable2" + ], + @readonly "_size": 2, + + "variable1": "Hello world", + "variable2": 10 +} + +``` + +| Attribute | Type | Description | +| ------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| (READONLY) \_lastSnapshot | number | Unix timestamp when the last snapshot was made. | +| (READONLY) \_keys | number | List of all variable keys inside the storage. | +| (READONLY) \_size | number | The amount of variables inside the storage. | +| [ key:string ] | any | Variables inside the runtime storage. Using the storage without an interface will work but is not generally advised. Please extent storage interface with an interface containing specific properties. | diff --git a/ModuleServerAPI.md b/ModuleServerAPI.md index 508aff9..1de3165 100644 --- a/ModuleServerAPI.md +++ b/ModuleServerAPI.md @@ -382,11 +382,39 @@ api.hasReferenceProperty(sceneId, propertyId); ## Snapshots -### onSnapshotRestore **(TODO)** +### onSnapshotRestore -### onSnapshotCreate **(TODO)** +Register a listener that will be called when a snapshot is recalled and the runtime storage is restored. -### getRuntimeStorage **(TODO)** +```javascript +api.ononSnapshotRestore(callback); +``` + +| Argument | Type | Description | +| -------- | -------- | ---------------------------------------------------- | +| callback | Function | Callback will be called when a snapshot is restored. | + +### onSnapshotCreate + +Register a listener that will be called before a snapshot is taken, this makes it possible to add variable to the storage before the snapshot happens. + +```javascript +api.onSnapshotCreate(callback); +``` + +| Argument | Type | Description | +| -------- | -------- | ------------------------------------------------------- | +| callback | Function | Callback will be called before the snapshot is created. | + +### getRuntimeStorage + +Get the variable storage object. + +```javascript +api.getRuntimeStorage(); +``` + +**Returns** [RuntimeStorage](./ModuleApiGameLibRuntimeStorage) _The runtime storage object._ ## Last State diff --git a/_Sidebar.md b/_Sidebar.md index d8a17cf..034480f 100644 --- a/_Sidebar.md +++ b/_Sidebar.md @@ -35,11 +35,13 @@ - [Axios](https://axios-http.com/docs/instance) - ModuleApi Shared - - [GameLib GameDetails](./ModuleApiGameLibGameDetails) - - [GameLib EndScreen](./ModuleAPIGameLibEndScreen) - - [GameLib TimeSpan](./ModuleApiGameLibTimeSpan) - - [GameLib FrameCycle](./ModuleApiGameLibFrameCycle) - - [GameLib Ratio](./ModuleAPIGameLibRatio) + - [RuntimeStorage](./ModuleApiGameLibRuntimeStorage) + - Gamelib + - [GameLib GameDetails](./ModuleApiGameLibGameDetails) + - [GameLib EndScreen](./ModuleAPIGameLibEndScreen) + - [GameLib TimeSpan](./ModuleApiGameLibTimeSpan) + - [GameLib FrameCycle](./ModuleApiGameLibFrameCycle) + - [GameLib Ratio](./ModuleAPIGameLibRatio) - [Module Debugging](./ModuleDebugging) - [ModuleStore](./ModuleStore)