Is this function the code on disk?
lua_function_sourceLocate a Lua function's definition and check if the running realm's bytecode matches the file on disk, so edited addon tests are trustworthy.
Instructions
Tells where a function was defined and whether the game runs the current code of that file: its bytecode is compared with the file compiled again from disk, in the same realm. Use it before trusting a test result after an edit (a map that was not reloaded, a file the client got from the server, another copy of the addon). Pick the realm the function lives in (default menu in client mode, server on srcds: addon code is usually in 'server' or 'client'). The file is found like the engine does (mounted Lua folder first, then lua/, gamemodes/, addons). Result: {source ("@" as the engine names it), linedefined, lastlinedefined, file/disk (absolute; the copy this realm ran), from_mount (true: it came from the mounted Lua folder, recorded when the folder was put in front of the realm's Lua path; false: the installed copy), mount_has_file, provenance (mount_in_place_at_load | reloaded_from_mount | installed | not_on_disk | no_file), file_age_s, matches_disk: true (same code) | false (edited since it was loaded, or another copy) | null (no file: code from lua_exec/RunString, or only inside a .gma), line_on_disk (where it starts now), note}. Example: {"realm": "server", "expr": "MyAddon.Update"}.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"expr": "<expr>"
},
"name": "lua_function_source"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes | Lua expression giving the function, e.g. 'MyAddon.Update' or 'hook.GetTable().Think.MyHook'. | |
| realm | No | Lua state to run in. Default: menu in client mode, which has no game libraries (ents, util.TraceLine, players...): pass 'server' or 'client' for game code; they exist only once a map is loaded (map_load). On srcds: server (the default; no menu or client realm). | |
| 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. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| disk | No | ||
| file | No | ||
| next | No | ||
| note | No | ||
| source | Yes | ||
| warning | No | ||
| next_call | No | ||
| file_age_s | No | ||
| from_mount | No | ||
| provenance | No | ||
| answered_by | No | ||
| linedefined | Yes | ||
| loaded_from | No | ||
| line_on_disk | No | ||
| matches_disk | Yes | ||
| mount_has_file | No | ||
| truncated_note | No | ||
| lastlinedefined | Yes | ||
| provenance_note | No | ||
| version_warning | No |