Skip to content

Commit

Permalink
Add lua log function next to print function which only writes to the …
Browse files Browse the repository at this point in the history
…log file.
  • Loading branch information
daid committed May 3, 2024
1 parent 1915871 commit 281dde9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/gameGlobalInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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");
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");

0 comments on commit 281dde9

Please sign in to comment.