From 78b1a4e61449cc85b60b17b9d78d412776b4d083 Mon Sep 17 00:00:00 2001 From: Marrub Date: Tue, 10 Mar 2015 16:14:12 -0400 Subject: [PATCH] added base/math/string libraries, no print() --- dlls/gslua.cpp | 4 ++++ dlls/lua/lbaselib.c | 24 ------------------------ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/dlls/gslua.cpp b/dlls/gslua.cpp index 948e88c..3baf7d4 100755 --- a/dlls/gslua.cpp +++ b/dlls/gslua.cpp @@ -61,6 +61,10 @@ void LuaInit(void) gsLib_GLOBALS[LF_PRINT_CONSOLE].value.fn = LUA_PrintConsole; g_L = luaL_newstate(); + luaopen_base(g_L); + luaopen_math(g_L); + luaopen_string(g_L); + g_bLuaInitialized = TRUE; ALERT(at_console, "[HLua] Lua initialized.\n"); diff --git a/dlls/lua/lbaselib.c b/dlls/lua/lbaselib.c index a240395..9a219f8 100755 --- a/dlls/lua/lbaselib.c +++ b/dlls/lua/lbaselib.c @@ -20,29 +20,6 @@ #include "lauxlib.h" #include "lualib.h" - -static int luaB_print (lua_State *L) { - int n = lua_gettop(L); /* number of arguments */ - int i; - lua_getglobal(L, "tostring"); - for (i=1; i<=n; i++) { - const char *s; - size_t l; - lua_pushvalue(L, -1); /* function to be called */ - lua_pushvalue(L, i); /* value to print */ - lua_call(L, 1, 1); - s = lua_tolstring(L, -1, &l); /* get result */ - if (s == NULL) - return luaL_error(L, "'tostring' must return a string to 'print'"); - if (i>1) lua_writestring("\t", 1); - lua_writestring(s, l); - lua_pop(L, 1); /* pop result */ - } - lua_writeline(); - return 0; -} - - #define SPACECHARS " \f\n\r\t\v" static const char *b_str2int (const char *s, int base, lua_Integer *pn) { @@ -481,7 +458,6 @@ static const luaL_Reg base_funcs[] = { {"next", luaB_next}, {"pairs", luaB_pairs}, {"pcall", luaB_pcall}, - {"print", luaB_print}, {"rawequal", luaB_rawequal}, {"rawlen", luaB_rawlen}, {"rawget", luaB_rawget},