Fate/filter API
From Quasar-RCE
Jump to navigationJump to search
File filters in FPX are sandboxed lua scripts, used to provide advanced editing functionality to mods on deployment. The lua engine is 5.1.4 with functionality limited by the sandbox environment.
Of major note, a number of functions and libraries that provide access to the file system have been removed from the sandbox. Instead, as each filter script is ran as a function, the file's contents being accessed can instead be found using the ‘…’ ellipses variable. The contents are edited and then returned, and FPX will store the returned string as the new file contents (or pass them along to the next filter). If a non-string value is returned, it is discarded instead and the filter is skipped.
Sandbox API
Key | Type | Description |
---|---|---|
Tables in Sandbox's `_G` | ||
_sandbox | Table | Self-references the sandbox's table. |
user_config | Table | The user's `config.ini` file contents as a table. |
modlist | Table | The user's current modlist data. |
string | Library | Standard string library. |
math | Library | Standard math library. |
os | Library | Limited OS library (only contains `os.time` and `os.date`). |
debug | Library | Limited debug library. |
coroutine | Library | Standard coroutine library. |
table | Library | Standard table library. |
Functions in Sandbox's `_G` | ||
spickle | Function | Visually represents the structure of a table as a string (for debugging). |
Function | Quick formatted console print. | |
console_print | Function | Formatted print; provide your own logging level (1-4). |
load | Function | Lua's `load()` function with sandbox limitations. |
loadstring | Function | Lua's `loadstring()` function with sandbox limitations. |
loadfile | Function | Lua's `loadfile()` function with sandbox limitations. |
dofile | Function | Sandboxed `loadfile`, but with instant execution. |
require | Function | require is a stub in the sandbox's context and has no functionality. |
read_mod_file | Function | Reads a file relative to the user's mod directory. |
read_game_file | Function | Reads a file relative to the user's game directory. |
Additional Values in Sandbox's `_G` | ||
… | String | Script mods read this string to get the contents of the file they are editing. Returning a string saves any edits made. |