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:
Name | Type | Description |
---|---|---|
fileName | string | The name of the Lua Script file without the path. |
Returns:
type | Description |
---|---|
object | The 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