library library
Summary
Functions
Get(strName, tParent)shared
Returns a library table, creating it if it does not exist.
New(strName, tParent)shared
Creates a library table, or returns it if it already exists.
Creates a class table that can be called to create instances.
Functions
Returns a library table, creating it if it does not exist.
library itself can be called as a shortcut: library('door', cw).
Parameters
- strName String Name of the library
- tParent Map optional, defaults to
_GTable the library is stored in
Returns
- Map The library table
See also
Creates a library table, or returns it if it already exists.
library.New('door', cw) -- creates cw.door
Parameters
- strName String Name of the library
- tParent Map optional, defaults to
_GTable the library is stored in
Returns
- Map The library table
See also
library.NewClass(strName, tParent, CExtends)
shared gamemodes/catwork/gamemode/core/sh_kernel.lua:724Creates a class table that can be called to create instances.
Calling the class creates a new object with the class as its metatable and a copy of its
fields, runs the base class (if any) and then the constructor, which is the method named after
the class. Constructor errors are printed instead of raised. The class gets ClassName and
BaseClass fields.
library.NewClass('CItem', _G)
function CItem:CItem(name)
self.name = name
end
local item = CItem('Crowbar')
Parameters
- strName String Name of the class and of its constructor method
- tParent Map optional, defaults to
_GTable the class is stored in - CExtends Map optional, defaults to
nilBase class whose fields are copied into the class metatable
Returns
- Map The class table