Orion Solutions Docs
ORION SOLUTIONS LUA API

Orion Libraries

Load Orion-hosted Lua modules with the standard require function.

Orion Solutions can provide reusable Lua library files from the server. These modules are loaded into the client before scripts run and are available through the standard Lua require function.

Require An Orion Library

require("Orion/<library>"): any

Prefix the library path with Orion/. The prefix selects the Orion-hosted library registry while keeping normal Lua require behaviour available for other module names.

Example

local math_utils = require("Orion/math_utils")

print(math_utils.add(10, 20))

Library Format

An Orion library is a normal Lua module. It can create a table containing functions and return that table to the script that required it.

local M = {}

function M.add(a, b)
    return a + b
end

function M.subtract(a, b)
    return a - b
end

return M

Nested Libraries

Libraries may be organised into folders. The folder path is preserved in the module name.

local strings = require("Orion/utility/string")

Module Cache

Each script runtime caches Orion modules after their first successful load. Requiring the same Orion module again in the same script returns the cached module value instead of executing the module source again.

local first = require("Orion/math_utils")
local second = require("Orion/math_utils")

print(first == second) -- true

Errors

Invalid paths, missing libraries, circular dependencies, compile errors and runtime errors are reported as Lua errors to the script that called require.

Path Format

Use forward slashes and omit the .lua extension. For example, a library named utility/string is loaded with require("Orion/utility/string").