diff --git a/Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.Server.cpp b/Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.Server.cpp index 99482dccae4..34c23149592 100644 --- a/Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.Server.cpp +++ b/Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.Server.cpp @@ -686,6 +686,25 @@ int CLuaFunctionDefs::SetServerConfigSetting(lua_State* luaVM) return 1; } +int CLuaFunctionDefs::GetServerEnvironmentValue(lua_State* luaVM) +{ + SString strName; + + CScriptArgReader argStream(luaVM); + argStream.ReadString(strName); + + if (!argStream.HasErrors()) + { + lua_pushstring(luaVM, getenv(strName)); + return 1; + } + else + m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage()); + + lua_pushboolean(luaVM, false); + return 1; +} + int CLuaFunctionDefs::shutdown(lua_State* luaVM) { SString strReason; diff --git a/Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.h b/Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.h index 120d712be03..e89a3947cb4 100644 --- a/Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.h +++ b/Server/mods/deathmatch/logic/lua/CLuaFunctionDefs.h @@ -111,6 +111,7 @@ class CLuaFunctionDefs LUA_DECLARE(SetServerPassword); LUA_DECLARE(GetServerConfigSetting); LUA_DECLARE(SetServerConfigSetting); + LUA_DECLARE(GetServerEnvironmentValue); LUA_DECLARE(ClearChatBox); LUA_DECLARE(shutdown); diff --git a/Server/mods/deathmatch/logic/lua/CLuaManager.cpp b/Server/mods/deathmatch/logic/lua/CLuaManager.cpp index d45cec6955e..bfb7bc08f1a 100644 --- a/Server/mods/deathmatch/logic/lua/CLuaManager.cpp +++ b/Server/mods/deathmatch/logic/lua/CLuaManager.cpp @@ -233,6 +233,7 @@ void CLuaManager::LoadCFunctions() {"getServerPassword", CLuaFunctionDefs::GetServerPassword}, {"setServerPassword", CLuaFunctionDefs::SetServerPassword}, {"getServerConfigSetting", CLuaFunctionDefs::GetServerConfigSetting}, + {"getServerEnvironmentValue", CLuaFunctionDefs::GetServerEnvironmentValue}, {"clearChatBox", CLuaFunctionDefs::ClearChatBox}, // Loaded map funcs