Custom Files Lua Scripting

Synopsis

When using CustomFiles, you can use Lua to write Path Handler scripts that are executed when files are requested by the game. These files can redirect the file to a different file or create the file dynamically using various Lua functions.

The hack uses Lua 5.3.4. Compiled Lua files are not supported.

Allowed Functions/Variables

This is a custom version of Lua that disallows the usage of much of Lua's included functionality.

This is a list of base Lua functions and variables that are allowed.

  • _G
  • _VERSION
  • coroutine.create
  • coroutine.resume
  • coroutine.running
  • coroutine.status
  • coroutine.wrap
  • coroutine.yield
  • debug.getinfo
  • debug.traceback
  • debug.upvalueid
  • error
  • ipairs
  • math.abs
  • math.acos
  • math.asin
  • math.atan
  • math.atan2
  • math.ceil
  • math.cos
  • math.cosh
  • math.deg
  • math.exp
  • math.floor
  • math.fmod
  • math.frexp
  • math.huge
  • math.ldexp
  • math.log
  • math.log10
  • math.max
  • math.min
  • math.modf
  • math.pi
  • math.pow
  • math.rad
  • math.sin
  • math.sinh
  • math.sqrt
  • math.tan
  • math.tanh
  • next
  • os.clock
  • os.date
  • os.difftime
  • os.exit
  • os.time
  • pairs
  • pcall
  • print
  • select
  • string.byte
  • string.char
  • string.find
  • string.format
  • string.gmatch
  • string.gsub
  • string.len
  • string.lower
  • string.match
  • string.rep
  • string.reverse
  • string.sub
  • string.upper
  • table.insert
  • table.maxn
  • table.remove
  • table.sort
  • table.unpack
  • tonumber
  • tostring
  • type
  • utf8.char
  • utf8.charpattern
  • utf8.codepoint
  • utf8.codes
  • utf8.len
  • utf8.offset
  • xpcall

The following functions are also supported with a custom implementation:

  • dofile
  • load
  • loadfile
  • math.random

Documentation of these functions and variables can be found in in the Lua manual.

Custom Functions

Function Name Description  Initial Release
Alert Shows a Windows message box for debugging purposes with an "OK" button. ?
ComparePaths Compare two paths. ?
Confirm Shows a Windows message for debugging purposes with an "OK" button and a "Cancel" button. ?
DirectoryGetEntries   ?
DirectoryRecursiveCreate   ?
Exists   ?
FixSlashes   ?
GetEnabledMods   ?
GetFileExtension   ?
GetFileName   ?
GetLauncherVersion Gets the current version of the Mod Launcher. 1.19
GetMainMod Get the name of the current main mod. 1.19
GetModName   ?
GetModPath   ?
GetPath Gets the path of the file being requested in a Path Handler script. ?
GetPathParent   ?
GetSetting Get the value of a setting for a mod. ?
GetSettings Get the value of all of the settings of a mod. 1.19
GetTime Get the amount of seconds the game has been running for. ?
IsModEnabled Gets whether or not a mod, mod hack or framework is enabled. ?
IsHackLoaded   ?
IsTesting Gets whether or not the user currently has the launcher in Testing mode via the -testing command line argument. 1.19
IsWriting   ?
Output   ?
Redirect   ?
RemoveFileExtension   ?
UseCallbacks   1.19
WildcardMatch   ?

Virtual File System Mount Points

This hack has access to various mount points within the Mod Launcher's virtual file system.

Path Description
/GameData/ Allows access to files within the game's install directory (not including within RCFs) and within the "CustomFiles" folder of any enabled mod.
/GameDir/ Allows access to the game's install directory (bypassing any CustomFiles folders).
/Mods/MODNAME Allows access to the folder of any enabled mod.
/UserData/SavedGames Allows access to the current saved games directory.

This could be the game directory if no main mod is enabled (depending on the user's "Always Keep Saved Games Separate" setting) or the main mod's saved games directory within the launcher's saved games directory if a main mod is enabled.
/UserData/Screenshots Allows access to the screenshots directory (or the folder inside the screenshots directory for the current main mod if a main mod is enabled).
/UserData/Settings Allows access to the folder containing "simpsons.ini".

This may be the same as "/GameData" depending on the user's "Keep Game Settings Separate" setting.
Back to top