diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-06-18 09:11:29 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-06-18 09:11:29 -0400 |
commit | aff78224a026bbf17e6ac4818228c0e1814c4226 (patch) | |
tree | 16f7f817a638ac0f0da9a14ce7d3048347252671 /indra/llcommon | |
parent | 5b6a5c757deaba3c2b361eb49f2e61630fe3eb47 (diff) |
Make lluau::source_path() report top-level script path.
source_path() previously reported the path of the module containing the
current (lowest-level) Lua function. The effect was that the Floater.lua
module would always try to look up the XUI file relative to
scripts/lua/require.
It makes more intuitive sense to make source_path() return the path containing
the top-level script, so that a script engaging the Floater.lua module looks
for the XUI file relative to the script.
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/lua_function.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/indra/llcommon/lua_function.cpp b/indra/llcommon/lua_function.cpp index cd1a0cd562..3e3934c9c1 100644 --- a/indra/llcommon/lua_function.cpp +++ b/indra/llcommon/lua_function.cpp @@ -75,8 +75,11 @@ fsyspath lluau::source_path(lua_State* L) { //Luau lua_Debug and lua_getinfo() are different compared to default Lua: //see https://github.com/luau-lang/luau/blob/80928acb92d1e4b6db16bada6d21b1fb6fa66265/VM/include/lua.h + // In particular: + // passing level=1 gets you info about the deepest function call + // passing level=lua_stackdepth() gets you info about the topmost script lua_Debug ar; - lua_getinfo(L, 1, "s", &ar); + lua_getinfo(L, lua_stackdepth(L), "s", &ar); return ar.source; } |