diff --git a/Util/LuaUtil.h b/Util/LuaUtil.h index f47869a8a..fadf78d6f 100644 --- a/Util/LuaUtil.h +++ b/Util/LuaUtil.h @@ -33,8 +33,7 @@ void LUA_print(T number) { } // Check if the lua function is defined -bool lua_function_exists(lua_State* lua_state, const char* name) -{ +inline bool lua_function_exists(lua_State* lua_state, const char* name) { luabind::object g = luabind::globals(lua_state); luabind::object func = g[name]; return func && (luabind::type(func) == LUA_TFUNCTION); @@ -42,13 +41,12 @@ bool lua_function_exists(lua_State* lua_state, const char* name) // Add the folder contain the script to the lua load path, so script can easily require() other lua scripts inside that folder, or subfolders. // See http://lua-users.org/wiki/PackagePath for details on the package.path syntax. -void luaAddScriptFolderToLoadPath(lua_State* myLuaState, const char* fileName) { +inline void luaAddScriptFolderToLoadPath(lua_State* myLuaState, const char* fileName) { const boost::filesystem::path profilePath( fileName ); - if( !profilePath.parent_path().empty() ) { - const std::string folder = profilePath.parent_path().string(); - const std::string luaCode = "package.path = \"" + folder + "/?.lua;\" .. package.path"; - luaL_dostring( myLuaState, luaCode.c_str() ); - } + std::string folder = profilePath.parent_path().string(); + //TODO: This code is most probably not Windows safe since it uses UNIX'ish path delimiters + const std::string luaCode = "package.path = \"" + folder + "/?.lua;profiles/?.lua;\" .. package.path"; + luaL_dostring( myLuaState, luaCode.c_str() ); } #endif /* LUAUTIL_H_ */