Commit b419ee8e authored by Chen Bill's avatar Chen Bill Committed by GitHub

update interpreter::interpreter() (#501)

Now it only opens necessary libraries.
parent 11de7027
...@@ -21,28 +21,15 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -21,28 +21,15 @@ interpreter::interpreter(duel* pd): coroutines(256) {
no_action = 0; no_action = 0;
call_depth = 0; call_depth = 0;
//Initial //Initial
luaL_openlibs(lua_state); luaL_requiref(lua_state, "base", luaopen_base, 0);
lua_pushnil(lua_state); lua_pop(lua_state, 1);
lua_setglobal(lua_state, "io"); luaL_requiref(lua_state, "string", luaopen_string, 1);
lua_pushnil(lua_state); lua_pop(lua_state, 1);
lua_setglobal(lua_state, "os"); luaL_requiref(lua_state, "utf8", luaopen_utf8, 1);
lua_pushnil(lua_state); lua_pop(lua_state, 1);
lua_setglobal(lua_state, "package"); luaL_requiref(lua_state, "table", luaopen_table, 1);
lua_pushnil(lua_state); lua_pop(lua_state, 1);
lua_setglobal(lua_state, "debug"); luaL_requiref(lua_state, "math", luaopen_math, 1);
lua_pushnil(lua_state);
lua_setglobal(lua_state, "coroutine");
luaL_getsubtable(lua_state, LUA_REGISTRYINDEX, "_LOADED");
lua_pushnil(lua_state);
lua_setfield(lua_state, -2, "io");
lua_pushnil(lua_state);
lua_setfield(lua_state, -2, "os");
lua_pushnil(lua_state);
lua_setfield(lua_state, -2, "package");
lua_pushnil(lua_state);
lua_setfield(lua_state, -2, "debug");
lua_pushnil(lua_state);
lua_setfield(lua_state, -2, "coroutine");
lua_pop(lua_state, 1); lua_pop(lua_state, 1);
//open all libs //open all libs
scriptlib::open_cardlib(lua_state); scriptlib::open_cardlib(lua_state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment