Fix P_GetZAt for Lua

This commit is contained in:
Louis-Antoine 2020-05-18 16:16:45 +02:00
parent 74fa35221d
commit 4c37c18385

View file

@ -2184,16 +2184,18 @@ static int lib_evStartCrumble(lua_State *L)
static int lib_pGetZAt(lua_State *L) static int lib_pGetZAt(lua_State *L)
{ {
pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE));
fixed_t x = luaL_checkfixed(L, 2); fixed_t x = luaL_checkfixed(L, 2);
fixed_t y = luaL_checkfixed(L, 3); fixed_t y = luaL_checkfixed(L, 3);
//HUDSAFE //HUDSAFE
if (slope) if (lua_isnil(L, 1))
lua_pushfixed(L, P_GetSlopeZAt(slope, x, y));
else
{ {
fixed_t z = luaL_checkfixed(L, 4); fixed_t z = luaL_checkfixed(L, 4);
lua_pushfixed(L, P_GetZAt(slope, x, y, z)); lua_pushfixed(L, P_GetZAt(NULL, x, y, z));
}
else
{
pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE));
lua_pushfixed(L, P_GetSlopeZAt(slope, x, y));
} }
return 1; return 1;