API

class LibTSMCore
staticmethod NewComponent(name: string): LibTSMComponent

Creats a new component.

Parameters:

name (string) – The name of the component

staticmethod SetTimeFunction(timeFunc: fun(): number)

Sets the time function.

Parameters:

timeFunc (fun(): number) – A function which returns the time with high precision

staticmethod LoadAll()

Loads all modules.

staticmethod UnloadAll(maxTime: number): boolean

Unloads all modules.

Parameters:

maxTime (number) – The max time before aborting early

staticmethod ModuleInfoIterator(): fun(): number, string, number, number, nil, number

Returns an iterator over all available modules.

Returns:

_1 (fun(): number, string, number, number) – Iterator with fields: index, componentName, modulePath, loadTime, unloadTime

class LibTSMComponent
Init(self: LibTSMComponent, path: <T>): <T: LibTSMModule>

Creates a new module.

Parameters:

path (<T>) – The path of the module

DefineClassType(
    self: LibTSMComponent,
    name: <T>,
    parentClass?: Class,
    ...: "ABSTRACT"
): <T: Class>

Creates a new class type.

Parameters:
  • name (<T>) – The name of the class

  • parentClass? (Class) – The parent class

  • ... ("ABSTRACT") – Properties to define the class with

Include(self: LibTSMComponent, path: <T>): <T>

Returns an existing module.

Parameters:

path (<T>) – The path of the module

IncludeClassType(self: LibTSMComponent, name: <T>): <T>

Returns a class type.

Parameters:

name (<T>) – THe name of the class

From(self: LibTSMComponent, name: <T>): <T: LibTSMComponent>

Retrieves a component which the current component depends on.

Parameters:

name (<T>) – The name of the component

AddDependency(self: LibTSMComponent, name: string): LibTSMComponent

Adds a component as a dependency of the current component.

Parameters:

name (string) – The name of the component

class LibTSMModule
protected OnModuleLoad(self: LibTSMModule, func: fun())

Registers the function be called when the module is loaded.

Parameters:

func (fun()) – The function to call

protected OnModuleUnload(self: LibTSMModule, func: fun())

Registers the function be called when the module is unloaded.

Parameters:

func (fun()) – The function to call

protected OnModuleUnloadLate(self: LibTSMModule, func: fun())

Registers the function be called when the module is unloaded as late as possible in the process.

Parameters:

func (fun()) – The function to call