Hi @darkspike119,
A common way to set up Lua modules is to “bundle” various functions inside a table of that module, then return the table. In that way, you’ll gain access to the function within.
This is a very basic example where you have an external module and you make it accessible from another module or main.lua, and you also gain access to the function within the external module:
chooselevel.lua
[lua]
local M = {}
function M.unlockLevel( levelNum )
– your code/process to unlock level number of ‘levelNum’ value
end
return M
[/lua]
main.lua
[lua]
– require() the external module
local levelModule = require( “chooselevel” )
– set a local variable for the function in the external module
local unlockLevelFunction = levelModule.unlockLevel
– call the function in the external module
unlockLevelFunction( 2 )
[/lua]