From 281dde95d715365883a7f8d20123fc20dc084b1c Mon Sep 17 00:00:00 2001 From: Daid Date: Fri, 3 May 2024 11:14:50 +0200 Subject: [PATCH] Add lua log function next to print function which only writes to the log file. --- src/gameGlobalInfo.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gameGlobalInfo.cpp b/src/gameGlobalInfo.cpp index ea7db992e6..64be6a125b 100644 --- a/src/gameGlobalInfo.cpp +++ b/src/gameGlobalInfo.cpp @@ -799,7 +799,7 @@ static int getEEVersion(lua_State* L) /// Example: getEEVersion() -- returns 20221029 on EE-2022.10.29 REGISTER_SCRIPT_FUNCTION(getEEVersion); -static int luaPrint(lua_State* L) +static int luaLogPrint(lua_State* L, bool print) { string message; int n = lua_gettop(L); /* number of arguments */ @@ -836,7 +836,17 @@ static int luaPrint(lua_State* L) } } LOG(Info, "LUA:", message); - LuaConsole::addLog(message); + if (print) + LuaConsole::addLog(message); return 0; } -REGISTER_SCRIPT_FUNCTION_NAMED(luaPrint, "print"); \ No newline at end of file +static int luaPrint(lua_State* L) +{ + return luaLogPrint(L, true); +} +static int luaLog(lua_State* L) +{ + return luaLogPrint(L, false); +} +REGISTER_SCRIPT_FUNCTION_NAMED(luaPrint, "print"); +REGISTER_SCRIPT_FUNCTION_NAMED(luaLog, "log"); \ No newline at end of file