From 39869b4492d133f044b970826e5ee74782d3854d Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Wed, 31 May 2023 22:21:31 -0500 Subject: [PATCH 1/2] Expose P_TouchSpecialThing --- src/lua_baselib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 25fa38769..8409a8377 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2195,6 +2195,19 @@ static int lib_pDoMatchSuper(lua_State *L) return 0; } +static int lib_pTouchSpecialThing(lua_State *L) +{ + mobj_t *special = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + mobj_t *toucher = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + boolean heightcheck = lua_optboolean(L, 3); + NOHUD + INLEVEL + if (!special || !toucher) + return LUA_ErrInvalid(L, "mobj_t"); + P_TouchSpecialThing(special, toucher, heightcheck); + return 0; +} + // P_SPEC //////////// @@ -4133,6 +4146,7 @@ static luaL_Reg lib[] = { {"P_FloorzAtPos",lib_pFloorzAtPos}, {"P_CeilingzAtPos",lib_pCeilingzAtPos}, {"P_DoSpring",lib_pDoSpring}, + {"P_TouchSpecialThing",lib_pTouchSpecialThing}, {"P_TryCameraMove", lib_pTryCameraMove}, {"P_TeleportCameraMove", lib_pTeleportCameraMove}, From 2647b108406258aac6fcf8bf522cb2be8b68305c Mon Sep 17 00:00:00 2001 From: SMS Alfredo <65426124+SMS-Alfredo@users.noreply.github.com> Date: Sat, 1 Jul 2023 22:24:11 -0500 Subject: [PATCH 2/2] Require valid toucher.player --- src/lua_baselib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 8409a8377..1f8baedc2 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2204,6 +2204,8 @@ static int lib_pTouchSpecialThing(lua_State *L) INLEVEL if (!special || !toucher) return LUA_ErrInvalid(L, "mobj_t"); + if (!toucher->player) + return luaL_error(L, "P_TouchSpecialThing requires a valid toucher.player."); P_TouchSpecialThing(special, toucher, heightcheck); return 0; }