fix lua foo

master
neingeist 11 years ago
parent 1b2935353e
commit 065204dc85

@ -37,12 +37,22 @@ static int l_mysin(lua_State *L) {
int main(void) { int main(void) {
/* Set up Lua. */ /* Set up Lua. */
lua_State *L; lua_State *L;
L = lua_open(); L = luaL_newstate();
luaopen_base(L); /* Load necessary libs. */
luaopen_string(L); luaL_Reg lualibs[] = {
/* Alternatively: { "base", luaopen_base },
luaL_openlibs(L); */ { "string", luaopen_string },
{ NULL, NULL}
};
for(luaL_Reg *lib = lualibs; lib->func; lib++) {
printf("Loading %s\n", lib->name);
lib->func(L);
lua_setglobal(L, lib->name);
lua_settop(L, 0);
}
/* Alternatively, we could have called LuaL_openlibs(L) but that would have
loaded *all* libs. */
/* Register 'mysin'. */ /* Register 'mysin'. */
lua_pushcfunction(L, l_mysin); lua_pushcfunction(L, l_mysin);

Loading…
Cancel
Save