summaryrefslogtreecommitdiff
path: root/indra/newview/llluamanager.cpp
diff options
context:
space:
mode:
authornat-goodspeed <nat@lindenlab.com>2024-07-02 16:48:20 -0400
committerGitHub <noreply@github.com>2024-07-02 16:48:20 -0400
commit24e6c4ae23b24c7da36b2579069a062ffd882059 (patch)
tree51aa40d9d0e9f9b14bd777109f36b172a1554906 /indra/newview/llluamanager.cpp
parent14a05ec7ac2e2df5886e4dc7ae33ce57a4272b8d (diff)
parent9a3c770a3bf430da8878a8691cee9b726a5f026c (diff)
Merge pull request #1878 from secondlife/lua-paths
Add LuaAutorunPath, LuaCommandPath and LuaRequirePath settings.
Diffstat (limited to 'indra/newview/llluamanager.cpp')
-rw-r--r--indra/newview/llluamanager.cpp64
1 files changed, 7 insertions, 57 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp
index 3ed72c34f3..ccfa08078e 100644
--- a/indra/newview/llluamanager.cpp
+++ b/indra/newview/llluamanager.cpp
@@ -32,6 +32,7 @@
#include "llcoros.h"
#include "llerror.h"
#include "lleventcoro.h"
+#include "llsdutil.h"
#include "llviewercontrol.h"
#include "lua_function.h"
#include "lualistener.h"
@@ -265,27 +266,6 @@ void LLLUAmanager::runScriptLine(LuaState& L, const std::string& chunk, script_r
});
}
-void LLLUAmanager::runScriptOnLogin()
-{
-#ifndef LL_TEST
- std::string filename = gSavedSettings.getString("AutorunLuaScriptName");
- if (filename.empty())
- {
- LL_INFOS() << "Script name wasn't set." << LL_ENDL;
- return;
- }
-
- filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename);
- if (!gDirUtilp->fileExists(filename))
- {
- LL_INFOS() << filename << " was not found." << LL_ENDL;
- return;
- }
-
- runScriptFile(filename);
-#endif // ! LL_TEST
-}
-
std::string read_file(const std::string &name)
{
llifstream in_file;
@@ -330,31 +310,6 @@ LLRequireResolver::LLRequireResolver(lua_State *L, const std::string& path) :
luaL_argerrorL(L, 1, "cannot require a full path");
}
-/**
- * Remove a particular stack index on exit from enclosing scope.
- * If you pass a negative index (meaning relative to the current stack top),
- * converts to an absolute index. The point of LuaRemover is to remove the
- * entry at the specified index regardless of subsequent pushes to the stack.
- */
-class LuaRemover
-{
-public:
- LuaRemover(lua_State* L, int index):
- mState(L),
- mIndex(lua_absindex(L, index))
- {}
- LuaRemover(const LuaRemover&) = delete;
- LuaRemover& operator=(const LuaRemover&) = delete;
- ~LuaRemover()
- {
- lua_remove(mState, mIndex);
- }
-
-private:
- lua_State* mState;
- int mIndex;
-};
-
// push the loaded module or throw a Lua error
void LLRequireResolver::findModule()
{
@@ -384,18 +339,13 @@ void LLRequireResolver::findModule()
fail();
}
- std::vector<fsyspath> lib_paths
- {
- gDirUtilp->getExpandedFilename(LL_PATH_SCRIPTS, "lua", "require"),
-#ifdef LL_TEST
- // Build-time tests don't have the app bundle - use source tree.
- fsyspath(__FILE__).parent_path() / "scripts" / "lua" / "require",
-#endif
- };
-
- for (const auto& path : lib_paths)
+ LLSD lib_paths(gSavedSettings.getLLSD("LuaRequirePath"));
+ LL_DEBUGS("Lua") << "LuaRequirePath = " << lib_paths << LL_ENDL;
+ for (const auto& path : llsd::inArray(lib_paths))
{
- std::string absolutePathOpt = (path / mPathToResolve).u8string();
+ // if path is already absolute, operator/() preserves it
+ auto abspath(fsyspath(gDirUtilp->getAppRODataDir()) / path.asString());
+ std::string absolutePathOpt = (abspath / mPathToResolve).u8string();
if (absolutePathOpt.empty())
luaL_error(L, "error requiring module '%s'", mPathToResolve.u8string().data());