Library¶
The Library
class is the internal base class for libraries in Epip. It offers general-purpose utility methods, such as logging, debug flags, event systems, as well as integrations with some core Epip libraries to simplify the registration of resources.
Epip.InitializeLibrary()
is meant to be used to define libraries, though you are not intended to do so in your own mod - use Features instead.
Library contains integrations with the following core Epip libraries:
- Text (for TSK registration and organizing TSKs by library/feature within the localization sheet)
- UserVars (for namespacing)
- OOP (for containing related subclasses)
Perceptive readers will realize that these integrations indeed create circular dependencies. This concern is however pretty low on the list.
The class includes some methods to filter out unwanted logging, however the recommended way to filter it is to use the "control panel" UI (Feature_DebugMenu
, defaults to Left Ctrl+B) to set the logging level instead of calling the methods yourself anywhere.
Library Class¶
Inherits from Class
.
Methods¶
AddProfilingStep¶
Adds a step to the current profiling session.
Does nothing outside of Debug mode.
@param stepID string
AddSubscribableEvent¶
Registers a new event.
@param evName string
@param preventable boolean?
Defaults to false.
AddSubscribableHook¶
Registers a new hook.
@param evName string
@param preventable boolean?
Defaults to false.
Create¶
Initializes a table as a Library.
@param modTable string
@param id string
@param data Library
Debug¶
Show debug-level logging from this library.
Only works in Developer mode.
DebugLog¶
Log a value in Debug mode.
Dump¶
Dump a value to the console, in Debug mode.
@param msg any
EndProfiling¶
Ends the current profiling session.
Does nothing outside of Debug mode.
GetClass¶
Returns a class's base table.
@param className `T`
GetModVariable¶
Returns the value of a mod variable.
@param modGUID GUID
@param name string
GetPackagePrefix¶
Returns the package prefix for this library's subclasses.
GetTranslatedStringHandleForKey¶
@param localKey string
GetUserVariable¶
Gets the value of a user variable on an entity component.
@param component UserVarsLib_CompatibleComponent
@param variable string|UserVarsLib_UserVar
IsDebug¶
Returns whether :Debug()
has been ran successfully.
LogMethod¶
Log a message in the format "[MODULE] method(): msg"
@param method any
@param ... any
Mute¶
Stop all non-error, non-warning logging from this feature.
RegisterClass¶
Registers a class.
@param className `T`
@param class table
Class table.
@param parentClasses string[]?
Classes this one inherits from.
RegisterModVariable¶
Registers a mod variable.
@param modGUID GUID
@param name string
@param data UserVarsLib_ModVar
RegisterTranslatedString¶
Registers a TSK.
@param handle TranslatedStringHandle
@param tsk Library_TranslatedString
ModTable, FeatureID and Handle fields are auto-initialized.
RegisterTranslatedString¶
Table-only overload.
@param tsk Library_TranslatedString
ModTable, FeatureID and Handle fields are auto-initialized.
RegisterUserVariable¶
Registers a user variable.
@param name string
@param data UserVarsLib_UserVar?
SetModVariable¶
Sets the value of a mod variable.
@param modGUID GUID
@param name string
@param value any
SetUserVariable¶
Sets the value of a user variable.
@param component UserVarsLib_CompatibleComponent
@param variable string|UserVarsLib_UserVar
@param value any
ShutUp¶
Stop all non-error logging.
StartProfiling¶
Starts a profiling session.
Does nothing outside of Debug mode.
@param id string
Session ID.
__Setup¶
Invoked on SessionLoaded if the feature is not disabled.
Override to run initialization routines.
@virtual
__Test¶
Invoked on a small delay after SessionLoaded if Epip.IsDeveloperMode(true) is true and the feature is being debugged.
@virtual