#include #include #include #include BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved){ return TRUE; } static INT l_new(lua_State *L){ lua_newtable(L); lua_getglobal(L, "test"); lua_setmetatable(L, -2); return 1; } static INT l_deposit(lua_State *L){ MessageBox(NULL, "blah", "Deposit", MB_OK); return 0; } static INT l_withdraw(lua_State *L){ MessageBox(NULL, "blah", "Withdraw", MB_OK); return 0; } static const struct luaL_reg testlib [] = { {"new", l_new}, {"deposit", l_deposit}, {"withdraw", l_withdraw}, {NULL, NULL} /* sentinel */ }; INT luaopen_test(lua_State *L){ luaL_register(L, "test", testlib); lua_setfield(L, -1, "__index"); return 1; }