diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lua-interface.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/lua-interface.cpp b/src/lua-interface.cpp index 8b31f59..5cb47fe 100644 --- a/src/lua-interface.cpp +++ b/src/lua-interface.cpp @@ -242,6 +242,8 @@ static int StartTaskLoop(void * foo) { } #endif +static String searchpath; + class Luabaselua_interface : public LuaObject { public: static void pushstatics(Lua *) throw (GeneralException); @@ -368,7 +370,7 @@ int sLua_baselua_interface::baselua_interface_proceed_statics(Lua * L, int n, in #endif #endif } else { - LuaLoadPlugin(filename, L); + LuaLoadPlugin(filename, searchpath, L); } break; case BASELUA_INTERFACE_UNLINK: @@ -860,6 +862,20 @@ virtual int startup() throw (GeneralException) { showbanner(); + bool passthru = true; + try { + new Archive(argv[0], ARCHIVE_EXECUTABLE); + } + catch (...) { + passthru = false; + } + +#ifndef _WIN32 + ssize_t slashpos = argv[0].strrchr('/'); + if (slashpos >= 0) + searchpath = argv[0].extract(0, slashpos); +#endif + /* Let's start parsing options */ while ((c = getopt_long(argc, argv, "Hhva:ile:bg:m::s::t::f:z", long_options, NULL)) != EOF) { @@ -998,13 +1014,6 @@ virtual int startup() throw (GeneralException) { built.write(lua_interface_light_lua, size_lua_interface_light_lua); try { - bool passthru = true; - try { - new Archive(argv[0], ARCHIVE_EXECUTABLE); - } - catch (...) { - passthru = false; - } L->load(&built); L->push("lua_interface_light_main"); L->gettable(LUA_GLOBALSINDEX); |