There is a C code that describes the redirect of the print function from lua (lua5.1.dll) to its handler. Help translate it to Delphi?
#include <iostream> #include "lua.hpp" static int l_my_print(lua_State* L) { int nargs = lua_gettop(L); std::cout << "in my_print:"; for (int i=1; i <= nargs; ++i) { std::cout << lua_tostring(L, i); } std::cout << std::endl; return 0; } static const struct luaL_Reg printlib [] = { {"print", l_my_print}, {NULL, NULL} /* end of array */ }; int main(void) { lua_State* L = luaL_newstate(); luaL_openlibs(L); lua_getglobal(L, "_G"); luaL_setfuncs(L, printlib, 0); Lua_pop(L, 1); luaL_dostring(L, "print(\"Hello from Lua\")"); lua_close(L); return 0; } Ps. The wrapper for the LUA took from here https://github.com/danieleteti/lua4delphi