From 1d11797b476ee49ee88bb2740e7e932396e29872 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 30 Oct 2017 20:09:41 +0000 Subject: [PATCH] Added six new functions from p_spec.c/h to Lua --- src/lua_baselib.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 4d845df52..9a16a1a0b 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1655,6 +1655,78 @@ static int lib_pPlayerTouchingSectorSpecial(lua_State *L) return 1; } +static int lib_pFindLowestFloorSurrounding(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + lua_pushfixed(L, P_FindLowestFloorSurrounding(sector)); + return 1; +} + +static int lib_pFindHighestFloorSurrounding(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + lua_pushfixed(L, P_FindHighestFloorSurrounding(sector)); + return 1; +} + +static int lib_pFindNextHighestFloor(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + fixed_t currentheight; + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + // defaults to floorheight of sector arg + currentheight = (fixed_t)luaL_optinteger(L, 2, sector->floorheight); + lua_pushfixed(L, P_FindNextHighestFloor(sector, currentheight)); + return 1; +} + +static int lib_pFindNextLowestFloor(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + fixed_t currentheight; + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + // defaults to floorheight of sector arg + currentheight = (fixed_t)luaL_optinteger(L, 2, sector->floorheight); + lua_pushfixed(L, P_FindNextLowestFloor(sector, currentheight)); + return 1; +} + +static int lib_pFindLowestCeilingSurrounding(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + lua_pushfixed(L, P_FindLowestCeilingSurrounding(sector)); + return 1; +} + +static int lib_pFindHighestCeilingSurrounding(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + lua_pushfixed(L, P_FindHighestCeilingSurrounding(sector)); + return 1; +} + static int lib_pFindSpecialLineFromTag(lua_State *L) { INT16 special = (INT16)luaL_checkinteger(L, 1); @@ -2512,6 +2584,12 @@ static luaL_Reg lib[] = { {"P_DoSuperTransformation",lib_pDoSuperTransformation}, {"P_ExplodeMissile",lib_pExplodeMissile}, {"P_PlayerTouchingSectorSpecial",lib_pPlayerTouchingSectorSpecial}, + {"P_FindLowestFloorSurrounding",lib_pFindLowestFloorSurrounding}, + {"P_FindHighestFloorSurrounding",lib_pFindHighestFloorSurrounding}, + {"P_FindNextHighestFloor",lib_pFindNextHighestFloor}, + {"P_FindNextLowestFloor",lib_pFindNextLowestFloor}, + {"P_FindLowestCeilingSurrounding",lib_pFindLowestCeilingSurrounding}, + {"P_FindHighestCeilingSurrounding",lib_pFindHighestCeilingSurrounding}, {"P_FindSpecialLineFromTag",lib_pFindSpecialLineFromTag}, {"P_SwitchWeather",lib_pSwitchWeather}, {"P_LinedefExecute",lib_pLinedefExecute},