Hi Roy,
Yes you can. The basics are fairly straightforward.
So in ‘main.lua’ something like:
require("scripts.myOtherLuaFile"); helloWorld();
In ‘myOtherLuaFile.lua’:
function helloWorld() print("Hello World"); end;
“scripts.myOtherLuaFile” uses dot notation for the path, so “scripts/interface/other/myOtherLuaFile.lua” becomes “scripts.interface.other.myOtherLuaFile”.
I rarely do this however, because you end up with scoping issues and loads of global functions.
A better solution is to use ‘modular classes’. This emulates class and object behaviour in lua and keeps things a lot neater.
So ‘myOtherLuaFile.lua’ becomes:
local publicClass={}; function publicClass.helloWorld() print("Hello World"); end; return publicClass;
In ‘main.lua’
local myClass = require("scripts.myOtherLuaFile"); myClass.helloWorld();
Hope that helps!