Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int l_getsize(lua_State* L)
- {
- auto const grid_ptr = checkgrid(L);
- if (!grid_ptr)
- return 0;
- lua_newtable(L);//size
- lua_pushinteger(L, grid_ptr->Size.x);
- lua_setfield(L, -2, "x");
- lua_pushinteger(L, grid_ptr->Size.y);
- lua_setfield(L, -2, "y");
- return 1;
- }
- /*эту функцию просто взял с интернета, в 5.1 такой функции нет*/
- static void luaL_setfuncs(lua_State* L, const luaL_Reg* l, int nup) {
- luaL_checkstack(L, nup + 1, "too many upvalues");
- for (; l->name != NULL; l++) { /* fill the table with given functions */
- int i;
- lua_pushstring(L, l->name);
- for (i = 0; i < nup; i++) /* copy upvalues to the top */
- lua_pushvalue(L, -(nup + 1));
- lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
- lua_settable(L, -(nup + 3));
- }
- lua_pop(L, nup); /* remove upvalues */
- }
- CORONA_EXPORT int luaopen_plugin_helloplug (lua_State* L)
- {
- using namespace Corona;
- luaL_newmetatable(L, GRID_META);
- lua_pushvalue(L, -1);
- lua_setfield(L, -2, "__index");
- luaL_Reg arraylib_m[] = {
- {
- "size", l_getsize
- },
- { nullptr, nullptr }
- };
- luaL_setfuncs(L, arraylib_m, 0);
- lua_newtable(L); // helloplug
- luaL_Reg arraylib_f[] = {
- {
- "sin_from_c", l_sin
- },
- {
- "GenerateAndCalculateCorridors", l_GenerateAndCalculateCorridors
- },
- { nullptr, nullptr }
- };
- luaL_register(L, nullptr, arraylib_f);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement