On this page
Lua file: common/systems/import.lua
Import, replacement, and reload
Much of the game uses Import instead of ordinary Lua require. The implementation contains replacement,
append, module cache, dependency, and reload code.
Replace a file
An active mod can provide the same relative path as a base .lua or .santp file. If several active mods
replace the path, the last replacement in load order wins.
Append to a file
An active mod can place code at append/<original path>. The importer joins that text to the selected source and
executes both in one Lua chunk. Appended code can change exported globals and refer to locals declared earlier in
the chunk.
Module behavior
- The importer accepts
.luaand.santppaths. - Each file runs in a module environment that falls back to
_G. - Globals assigned by the file become fields in the returned module table.
- Imported modules are cached, and the importer records dependencies.
Reload code is not a dependable workflow
File-event processing can invalidate a changed module and its dependants. The default debug settings disable the
file watcher, and template reload inside OnFileChange is commented out. Treat reload as unfinished until a
runtime test proves otherwise.