Skip to main content

LUA.Import(string fileName)

You can import and use any Lua script (files with .lua extension) that you place directly under the Assets folder or other subdirectories with obvious exceptions of MLSDK and GIZMOS folder.

Parameters:

NameTypeDescription
fileNamestringThe name of the Lua Script file without the path.

Returns:

typeDescription
objectThe library object if exists.

Usage

---@type string
local fileName;


local val0 = LUA:Import(fileName)

Example

Let's have a Lua script file with we store some of the most used functions in it.

function Factorial(n)
if (n == 0) then
return 1
else
return n * factorial(n - 1)
end
end

We can utilize use the factorial function in other scripts by importing it.

do
LUA.Import("library");

local script = LUA.Script;

function script.start()
Debug.Log( Factorial(5) );
end
end