Load Lua from another folder first
lua_mountMount a local addon Lua folder into one running Garry's Mod process to test or override its Lua files at the next map load.
Instructions
Mounted Lua folder: plugs a folder (e.g. the git worktree of an addon: the folder that contains lua/) into THIS game process only. Every Lua lookup of this game then looks there first: autorun, include(), AddCSLuaFile (the client gets the folder's copy), lua_openscript, file.Read/Find with "LUA", and gmod-mcp's own lua_exec_file / lua_job {path} / lua_check / lua_reload / lua_function_source. A file in the folder hides the installed addon's file of the same Lua path; files only in the game are still loaded. Other games are not affected. Example: path "D:/dev/my-addon-wt" (a worktree of the addon installed as addons/my_addon): D:/dev/my-addon-wt/lua/autorun/my_addon.lua runs as autorun/my_addon.lua; D:/dev/my-addon-wt/lua/my_addon/core.lua is what include("my_addon/core.lua") loads, instead of addons/my_addon/lua/my_addon/core.lua; D:/dev/my-addon-wt/gamemodes//... are gamemode files; materials/, sound/, models/ and everything outside lua/ and gamemodes/ are not mounted. IT TAKES EFFECT AT THE NEXT MAP LOAD: call map_load right after (code already running stays until loaded again). No autorefresh: status.lua_mount.stale_files lists the folder's files that changed since each realm loaded them; lua_reload {mounted_changed: true} runs them again (or lua_reload {path}, or map_load); lua_function_source / lua_inspect of a function say which copy it came from (from_mount, disk). The engine names the folder's files from the folder's root (debug.getinfo source "@lua/my_addon/x.lua", not "@addons/my_addon/lua/my_addon/x.lua"). Only Lua (not materials, sounds, data/). path: the addon's root or its lua/ folder, absolute; null removes it (from the next map load); omitted: the current folder and the engine's Lua search paths (lsv = server, lcl = client). If the result says base_lua_mounted: false, remove the folder at once. engine_serves_folder (with a map loaded) is what the game's own file system says: false means it lists the folder but finds none of its files (a path it cannot read), so the game runs the installed code whatever else says mounted: a warning names the way out. A test client can start with one: instances_launch {lua_mount}. empty_cache (default true) empties the engine's Lua file cache. Windows game clients only (unsupported_platform on Linux; client only, unsupported on srcds). Full guide: resource mcpagent://guide, section "Mounted Lua folder".
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "lua_mount"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Absolute path of the folder to mount: the addon's root, i.e. the folder that contains lua/ (e.g. "D:/dev/my-addon-wt"), or that lua/ folder itself (same result). Must be outside the game folder. null or "" unmounts it (from the next map load). Omit it to read the current state. | |
| instance | No | Optional. Instance identifier (see instances_list). If present and different from the local instance, the call is relayed by the coordinator to that instance. | |
| empty_cache | No | Empty the engine's Lua file cache after the change (default true). | |
| allow_shadow | No | Mount a folder that replaces files of the game's own base Lua (lua/includes/init.lua...) anyway. Refused by default (error shadows_base_lua): such a folder made a client hang in its load. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| next | No | ||
| note | No | ||
| removed | No | ||
| warning | No | ||
| previous | No | ||
| lua_mount | No | ||
| next_call | No | ||
| hook_calls | No | ||
| mount_hook | No | ||
| answered_by | No | ||
| search_paths | No | ||
| cache_emptied | No | ||
| engine_serves | No | ||
| fs_first_slot | No | ||
| hook_path_ids | No | ||
| folder_missing | No | ||
| truncated_note | No | ||
| version_warning | No | ||
| base_lua_mounted | No | ||
| engine_serves_folder | No |