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) {
/* Set up Lua. */
lua_State *L;
L = lua_open();
L = luaL_newstate();
luaopen_base(L);
luaopen_string(L);
/* Alternatively:
luaL_openlibs(L); */
/* Load necessary libs. */
luaL_Reg lualibs[] = {
{ "base", luaopen_base },
{ "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'. */
lua_pushcfunction(L, l_mysin);

Loading…
Cancel
Save