ax.util¶
Source: gamemode/framework/util/util_file.lua
Utility helpers used across the Parallax framework (printing, file handling, text utilities, etc.).
Section: file_utilities
Documented functions: 7
Functions¶
ax.util:BuildDataPath(key, options)ax.util:DetectFileRealm(file)ax.util:EnsureDataDir(path)ax.util:Include(path, realm)ax.util:IncludeDirectory(directory, fromLua, toSkip, timeFilter)ax.util:ReadJSON(path)ax.util:WriteJSON(path, tbl)
ax.util:BuildDataPath(key, options)¶
Build a data file path based on key and scope options.
Parameters
| Name | Type | Description |
|---|---|---|
key |
string |
The data key |
options |
table\|nil |
Options table (scope, human) |
Returns
string: The data file path relative to DATA
Usage
ax.util:DetectFileRealm(file)¶
Utility helpers used across the Parallax framework (printing, file handling, text utilities, etc.). File and JSON helpers. Detects the realm of a file based on its name.
Parameters
| Name | Type | Description |
|---|---|---|
file |
string |
Filename to inspect (may include path) |
Returns
string: One of "client", "server", or "shared"
Usage
ax.util:EnsureDataDir(path)¶
Ensure parent directories exist for a given data path.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Data path to ensure directories for (e.g. "parallax/foo/bar/") |
Usage
ax.util:Include(path, realm)¶
Includes a Lua file, handling AddCSLuaFile/include based on realm.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Path to the Lua file to include (relative to gamemode) |
realm |
string\|nil |
Optional realm hint: "client", "server", or "shared" |
Returns
boolean: True if include/AddCSLuaFile was attempted
Usage
ax.util:IncludeDirectory(directory, fromLua, toSkip, timeFilter)¶
Recursively includes all Lua files found under a directory.
Parameters
| Name | Type | Description |
|---|---|---|
directory |
string |
Directory path to include (relative to gamemode) |
fromLua |
boolean\|nil |
Internal flag used when recursing from Lua |
toSkip |
table\|nil |
Optional set of filenames or directory names to skip |
Returns
boolean: True if directory processed
Usage
ax.util:ReadJSON(path)¶
Read and parse a JSON file from DATA safely.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Path in DATA to read |
Returns
table|nil: Parsed table or nil on error
Usage
ax.util:WriteJSON(path, tbl)¶
Write a table to a JSON file in DATA safely.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Path in DATA to write |
tbl |
table |
Table to serialize |
Returns
boolean: True on success
Usage