lje.env
Environment management, script context inspection, and global state control.
Functions
lje.env.get()
Returns the currently active global environment table, if one has been set via lje.env.set. Returns nothing if no environment is set.
Returns
| Type | Description |
|---|---|
table | nil | The active environment table, or |
lje.env.set(env)
Sets the active global environment table. This environment is automatically applied to functions compiled via lje.func.compile. Replaces any previously set environment.
Parameters
| Name | Type | Description |
|---|---|---|
env | table | The table to use as the environment. |
lje.env.current_script()
Returns the name of the currently executing LJE script, if any.
Returns
| Type | Description |
|---|---|
string | nil | The script name, or |
lje.env.current_script_path()
Returns the full path of the currently executing LJE script, if any.
Returns
| Type | Description |
|---|---|
string | nil | The script path, or |
lje.env.find_script_files(search_path)
Searches for files matching search_path relative to the current script's directory. Returns nil if no script is active.
Supports wildcard patterns, so if you wanted to find all files in detours/, you would do detours/*.
Parameters
| Name | Type | Description |
|---|---|---|
search_path | string | A path pattern to search for, relative to the current script. |
Returns
| Type | Description |
|---|---|
table | nil | An array of matching file path strings, or |
lje.env.is_lua_involved(frame_offset?)
Returns whether a Lua function is present in the call stack at or above the given frame offset.
Parameters
| Name | Type | Description |
|---|---|---|
frame_offset? | integer | The frame level to start checking from. Defaults to |
Returns
| Type | Description |
|---|---|
boolean |
|
lje.env.is_lje_involved(frame_offset?, max_depth?)
Returns whether an LJE frame is present in the call stack, starting from frame_offset and searching up to max_depth frames.
Parameters
| Name | Type | Description |
|---|---|---|
frame_offset? | integer | The frame level to start checking from. Defaults to |
max_depth? | integer | Maximum number of frames to search. Defaults to |
Returns
| Type | Description |
|---|---|
boolean |
|
lje.env.is_lje_frame(frame_offset?)
Returns whether the frame at exactly frame_offset is an LJE frame.
Parameters
| Name | Type | Description |
|---|---|---|
frame_offset? | integer | The frame level to check. Defaults to |
Returns
| Type | Description |
|---|---|
boolean |
|
lje.env.disable_metatables()
Globally disables metatable lookups. While disabled, __index, __newindex, and other metamethods will not be invoked. Re-enable with lje.env.enable_metatables.
lje.env.enable_metatables()
Re-enables metatable lookups after they have been disabled.
lje.env.save_random_state()
Saves the current PRNG state. Use in combination with lje.env.restore_random_state to create a temporary branch of randomness that does not permanently affect the global PRNG sequence.
Note: Saving and immediately restoring erases all randomness that occurred in between — subsequent calls will produce the same sequence. To avoid this, only save/restore at most once per logical frame, or re-seed the PRNG manually afterward.
lje.env.restore_random_state()
Restores the PRNG state previously saved by lje.env.save_random_state.
lje.env.remap_metatable(type_name, replacement)
Replaces the metatable used for a given Lua type name with replacement. Affects all future metatable lookups for that type.
Parameters
| Name | Type | Description |
|---|---|---|
type_name | string | The name of the type whose metatable should be remapped. |
replacement | table | The new metatable to use. |
lje.env.auth_metatable(metatable)
Marks a metatable as authorized, allowing it to bypass LJE's metatable access restrictions.
Parameters
| Name | Type | Description |
|---|---|---|
metatable | table | The metatable to authorize. |
lje.env.show_special_frames(show)
Controls whether special (internal LJE) frames are visible in stack introspection. Useful when debugging inter-LJE interactions.
Parameters
| Name | Type | Description |
|---|---|---|
show | boolean |
|