add core.capture_output

This commit is contained in:
MihailRis
2025-03-13 22:05:14 +03:00
parent ffac010e54
commit 1bb25e99c6
4 changed files with 37 additions and 3 deletions
+5 -3
View File
@@ -2,6 +2,8 @@
#include "libs/api_lua.hpp"
using namespace scripting;
/// @brief Modified version of luaB_print from lbaselib.c
int l_print(lua::State* L) {
int n = lua::gettop(L); /* number of arguments */
@@ -16,10 +18,10 @@ int l_print(lua::State* L) {
L,
LUA_QL("tostring") " must return a string to " LUA_QL("print")
);
if (i > 1) std::cout << "\t";
std::cout << s;
if (i > 1) *output_stream << "\t";
*output_stream << s;
lua::pop(L); /* pop result */
}
std::cout << std::endl;
*output_stream << std::endl;
return 0;
}