diff --git a/src/lua_infolib.c b/src/lua_infolib.c index a65ee23ebc913a62711e9960990c5935662b8dfd..f277f2651dcb0d858b50c1b5bb461de4a3658f62 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -1158,6 +1158,7 @@ enum mobjinfo_e mobjinfo_activesound, mobjinfo_flags, mobjinfo_raisestate, + mobjinfo_name, }; const char *const mobjinfo_opt[] = { @@ -1185,6 +1186,7 @@ const char *const mobjinfo_opt[] = { "activesound", "flags", "raisestate", + "name", NULL, }; @@ -1199,6 +1201,8 @@ static int mobjinfo_get(lua_State *L) I_Assert(info != NULL); I_Assert(info >= mobjinfo); + mobjtype_t id = info-mobjinfo; + switch (field) { case mobjinfo_doomednum: @@ -1273,6 +1277,21 @@ static int mobjinfo_get(lua_State *L) case mobjinfo_raisestate: lua_pushinteger(L, info->raisestate); break; + case mobjinfo_name: + if (id < MT_FIRSTFREESLOT) + { + lua_pushstring(L, MOBJTYPE_LIST[id]+3); + return 1; + } + + id -= MT_FIRSTFREESLOT; + if (id < NUMMOBJFREESLOTS && FREE_MOBJS[id]) + { + lua_pushstring(L, FREE_MOBJS[id]); + return 1; + } + + return 0; default: lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1));