Skip to content

Engine

The Engine object that is used to run a Luwow application.


initialize

void initialize()

Initializes a new Luau state, sets the environment variables, and sandboxes the state.

Returns


luaRequire

int luaRequire(Engine* engine, lua_State* L, std::string path_str);

Requires a module with the given path. The path must be used according to the require-by-string semantics.

If the path string points to a Luau module, its result after execution will be saved to the cache. Further requires will return this cached result to the Luau thread it was called from.

If the path string points to a native module, its exported functions will be returned in a table to the Luau thread it was called from.

Parameters

engine : Engine*

The pointer to the engine object.

The Luau thread that the function is being called with.

moduleName : const std::string&

The path string that can either point to an alias, Luau module, or a native module.

Returns

int


loadModuleFromBytecode

int loadModuleFromBytecode(lua_State* L, const std::string& moduleName, const std::string& bytecode, bool saveRef, bool useGivenState)

Executes a module with its bytecode in a new sandboxed Luau thread. If the engine has a debugger callback function, it will be called with the new thread state from this function.

Parameters

The Luau thread that the function is being called with.

moduleName : const std::string&

The module name that represents the Luau module.

bytecode : const std::string&

The bytecode of the Luau module that will be executed.

saveRef : bool

Whether or not the engine will save the result to the cache.

useGivenState : bool

Whether or not the engine will use the given lua_State* to create the new thread.

Returns

int


registerNativeModule

void registerNativeModule(std::shared_ptr<ILuauModule> module);

Registers a new native module to the engine. The module can then be required from Luau using its defined alias.

Parameters

The pointer to the ILuauModule that will be registered.

Returns


run

void run()

Runs the engine. Should be called the last after initialization.

If the engine has been given a package, it will attempt to run the package contents.

If the engine has been given a Luau module with a compiler callback, it will first compile the module using the callback, and then run it.

Returns