added base/math/string libraries, no print()

master
Marrub 2015-03-10 16:14:12 -04:00
parent fd9603ce3f
commit 78b1a4e614
2 changed files with 4 additions and 24 deletions

View File

@ -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");

View File

@ -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},