githubEdit

HoarderService

Noir.Services.HoarderService: NoirService

A service for easily saving/loading class instances within a service with minimal hassle.

Example (see Hoardable code sample for info on the class side of things):


Noir.Services.HoarderService:_IsSerializable(value)

Returns if a value is serializable.

Parameters

  • value: any

Returns

  • boolean


Noir.Services.HoarderService:_Serialize(tbl, _active)

Serializes a table for saving by removing all functions.

Used internally.

Parameters

  • tbl: table

  • _active: table<any, boolean>|nil

Returns

  • table


Adds class names as indices to a table of classes.

Used internally.

Parameters

  • classes: table<integer, NoirClass>

Returns

  • table<string, NoirClass>


Deserializes a serialized class instance.

Used internally.

Parameters

  • class: NoirHoardable|NoirClass

  • serialized: table

  • lookupClasses: table<string, NoirClass>

Returns

  • NoirClass


Sets up a save data category for a service if it doesn't exist.

Used internally.

Parameters

  • service: NoirService

  • tblName: string


Invokes the checkpoint for the provided service and class if any.

It then returns the result which should be whether or not to load the instance and an optional overwritten location for the instance.

Used internally.

Parameters

  • service: NoirService

  • class: NoirClass

  • instance: NoirHoardable

Returns

  • boolean

  • table|nil


Adds a checkpoint function for a service and class. It must return a boolean and an optional location for the instance.

if true is returned, the passed instance will be loaded.

if false is returned, the passed instance will not be loaded.

Example Checkpoint:

Parameters

  • service: NoirService

  • class: NoirHoardable

  • func: NoirHoarderCheckpoint


Saves the provided class instance within a service.

Parameters

  • service: NoirService

  • tblName: string - The name of the sub-table in the provided service's savedata to save the serialized instance to

  • instance: NoirHoardable


Unhoards the provided class instance within a service.

Parameters

  • service: NoirService

  • tblName: string

  • instance: NoirHoardable


Clears out saved instances for the provided service.

Parameters

  • service: NoirService

  • tblName: string


Loads all serialized class instances into a table in the provided service.

Parameters

  • service: NoirService

  • from: string - The name of the sub-table in the provided service's savedata to load the serialized instances from

  • to: table - The table to load the class instances into

  • class: NoirHoardable - The class the serialized instances are of

  • lookupClasses: table<integer, NoirClass> - A table of classes that the provided class may contain instances of. This is used to deserialize instances of classes that are not the provided class but may be contained within it.

Last updated