From 7f9175033d94752b79d4a9a1df825b749ee64dc1 Mon Sep 17 00:00:00 2001 From: kaysrishaq <62462173+kaysrishaq@users.noreply.github.com> Date: Tue, 14 Jul 2020 01:34:57 -0400 Subject: [PATCH] minor lua fixes minor lua fixes --- src/lua_consolelib.c | 2 +- src/lua_mobjlib.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 4fe234dee..36b1c3669 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -444,7 +444,7 @@ static int lib_consPrintf(lua_State *L) if (n < 2) return luaL_error(L, "CONS_Printf requires at least two arguments: player and text."); //HUDSAFE - INLEVEL + plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); if (!plr) return LUA_ErrInvalid(L, "player_t"); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 129339b96..e2826e160 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -165,14 +165,15 @@ static int mobj_get(lua_State *L) enum mobj_e field = Lua_optoption(L, 2, NULL, mobj_opt); lua_settop(L, 2); - INLEVEL - - if (!mo) { + if (!mo || !ISINLEVEL) { if (field == mobj_valid) { lua_pushboolean(L, 0); return 1; } - return LUA_ErrInvalid(L, "mobj_t"); + if (!mo) { + return LUA_ErrInvalid(L, "mobj_t"); + } else + return luaL_error(L, "Do not access an mobj_t field outside a level!"); } switch(field)