Project OutFox Wiki
Project OutFox home View the OutFox Wiki source on GitHub Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto mode Back to homepage


Introduced in OutFox Alpha 4, Modules are Lua files that provide snippet-like functions, tables, and metatables that can be quickly used and unloaded from memory when done. These can be loaded by using the LoadModule function. Depending on the return methodology from the module, it can be called in several ways.

Given the loading nature of modules, it is not recommended to use LoadModule directly if the function that will load it is called too quickly (like calling the module inside of a JudgmentMessageCommand), specially with modules that require file loading/saving. For that, it is recommended to cache the value returned by the module to then use.

-- An example: caching the result from the Load Configuration module into a variable.
local moduleResult = LoadModule("Config.Load.lua")("ShowOffsetBar","OutFoxPrefs.ini")

If the module gives a table:

return {

-- Load it by doing:
LoadModule( "MyModule.lua" )

If the module gives a function:

return function(arguments)
	print( arguments )

-- Load it by doing:
LoadModule( "MyModule.lua" )( arguments )

If the module needs a table:

local function(requiredtable)
	for i = 1,#requiredtable do
		print( requiredtable[i] )

-- Load it by doing:
LoadModule( "MyModule.lua" ){ arguments }
-- Or
LoadModule( "MyModule.lua" )({ arguments })

If the module needs a string:

return function(theString)
	print( "i'm printing ".. theString )

LoadModule( "MyModule.lua" )"a string" -- This is technically valid syntax, but it's not great for readability.
-- Or
LoadModule( "MyModule.lua" )( "a string" )