Skip to content
Snippets Groups Projects
Commit 0b7f8ca3 authored by MascaraSnake's avatar MascaraSnake
Browse files

Merge branch 'lua-mapthing-len' into 'next'

Lua mapthing len

See merge request STJr/SRB2!957
parents 7722d41b 4b7f0f49
No related branches found
No related tags found
No related merge requests found
...@@ -829,6 +829,15 @@ static int mapthing_set(lua_State *L) ...@@ -829,6 +829,15 @@ static int mapthing_set(lua_State *L)
return 0; return 0;
} }
static int mapthing_num(lua_State *L)
{
mapthing_t *mt = *((mapthing_t **)luaL_checkudata(L, 1, META_MAPTHING));
if (!mt)
return luaL_error(L, "accessed mapthing_t doesn't exist anymore.");
lua_pushinteger(L, mt-mapthings);
return 1;
}
static int lib_iterateMapthings(lua_State *L) static int lib_iterateMapthings(lua_State *L)
{ {
size_t i = 0; size_t i = 0;
...@@ -893,6 +902,9 @@ int LUA_MobjLib(lua_State *L) ...@@ -893,6 +902,9 @@ int LUA_MobjLib(lua_State *L)
lua_pushcfunction(L, mapthing_set); lua_pushcfunction(L, mapthing_set);
lua_setfield(L, -2, "__newindex"); lua_setfield(L, -2, "__newindex");
lua_pushcfunction(L, mapthing_num);
lua_setfield(L, -2, "__len");
lua_pop(L,1); lua_pop(L,1);
lua_newuserdata(L, 0); lua_newuserdata(L, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment