modules

Utilities for working with modules.

Require: require("Starlit/modules")

Data

Starlit.modules.onDelayedRequiresDone: starlit.LuaEvent

Triggered after all delayed requires have been loaded,

Function

Starlit.modules.delayedRequire(module: string): (module: table)

Requires a module after all modules have been initialised.

This is needed when importing a client module from shared, or a server module from either client or shared. This is generally bad style and should be avoided, but often necessary for networked timed actions which must be shared but usually have server/client only paths.

The result of this function is an empty table which, when ready, redirects indices to the correct module. If the module was not required yet or the require failed, an error is raised instead.

There may be a slight overhead to using these over a raw module: Timed actions are rarely performance sensitive so this shouldn’t be a concern generally, but if you need to squeeze out extra performance don’t use this and delay manually using events.

You will very likely want to annotate the return value of this function with @module module.

Parameters:

module (string) – Module path.

Returns:

module (table) – Delayed require module.

Starlit.modules.getDelayedRequireStatus(delayedRequire: table): (status: starlit.modules.DelayedRequireStatus)

Gets the current status of a delayed require.

Result is undefined if the argument is not a delayed require module.

Parameters:

delayedRequire (table) – Delayed require module.

Returns:

status (starlit.modules.DelayedRequireStatus) – Current status.