lib2.c 385 B

1234567891011121314151617181920212223
  1. #include "lua.h"
  2. #include "lauxlib.h"
  3. static int id (lua_State *L) {
  4. return lua_gettop(L);
  5. }
  6. static const struct luaL_Reg funcs[] = {
  7. {"id", id},
  8. {NULL, NULL}
  9. };
  10. LUAMOD_API int luaopen_lib2 (lua_State *L) {
  11. lua_settop(L, 2);
  12. lua_setglobal(L, "y"); /* y gets 2nd parameter */
  13. lua_setglobal(L, "x"); /* x gets 1st parameter */
  14. luaL_newlib(L, funcs);
  15. return 1;
  16. }