mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-17 09:32:33 +00:00
Added new functions as variables of polyobj_t:
* po.pointInside(po, x, y) as a wrapper for P_PointInsidePolyobj * po.mobjTouching(po, mo) as a wrapper for P_MobjTouchingPolyobj * po.mobjInside(po, mo) as a wrapper for P_MobjInsidePolyobj I can confirm that ":" syntax works with all the above, e.g. po:mobjInside(mo)
This commit is contained in:
parent
5f91833701
commit
f86dad2979
1 changed files with 60 additions and 1 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include "lua_libs.h"
|
#include "lua_libs.h"
|
||||||
|
|
||||||
enum polyobj_e {
|
enum polyobj_e {
|
||||||
|
// properties
|
||||||
polyobj_valid = 0,
|
polyobj_valid = 0,
|
||||||
polyobj_id,
|
polyobj_id,
|
||||||
polyobj_parent,
|
polyobj_parent,
|
||||||
|
@ -27,9 +28,14 @@ enum polyobj_e {
|
||||||
polyobj_thrust,
|
polyobj_thrust,
|
||||||
polyobj_flags,
|
polyobj_flags,
|
||||||
polyobj_translucency,
|
polyobj_translucency,
|
||||||
polyobj_triggertag
|
polyobj_triggertag,
|
||||||
|
// special functions
|
||||||
|
polyobj_pointInside,
|
||||||
|
polyobj_mobjTouching,
|
||||||
|
polyobj_mobjInside
|
||||||
};
|
};
|
||||||
static const char *const polyobj_opt[] = {
|
static const char *const polyobj_opt[] = {
|
||||||
|
// properties
|
||||||
"valid",
|
"valid",
|
||||||
"id",
|
"id",
|
||||||
"parent",
|
"parent",
|
||||||
|
@ -40,8 +46,50 @@ static const char *const polyobj_opt[] = {
|
||||||
"flags",
|
"flags",
|
||||||
"translucency",
|
"translucency",
|
||||||
"triggertag",
|
"triggertag",
|
||||||
|
// special functions
|
||||||
|
"pointInside",
|
||||||
|
"mobjTouching",
|
||||||
|
"mobjInside",
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
|
static int lib_polyobj_PointInside(lua_State *L)
|
||||||
|
{
|
||||||
|
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
|
||||||
|
fixed_t x = luaL_checkfixed(L, 2);
|
||||||
|
fixed_t y = luaL_checkfixed(L, 3);
|
||||||
|
INLEVEL
|
||||||
|
if (!po)
|
||||||
|
return LUA_ErrInvalid(L, "polyobj_t");
|
||||||
|
lua_pushboolean(L, P_PointInsidePolyobj(po, x, y));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lib_polyobj_MobjTouching(lua_State *L)
|
||||||
|
{
|
||||||
|
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
|
||||||
|
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||||
|
INLEVEL
|
||||||
|
if (!po)
|
||||||
|
return LUA_ErrInvalid(L, "polyobj_t");
|
||||||
|
if (!mo)
|
||||||
|
return LUA_ErrInvalid(L, "mobj_t");
|
||||||
|
lua_pushboolean(L, P_MobjTouchingPolyobj(po, mo));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lib_polyobj_MobjInside(lua_State *L)
|
||||||
|
{
|
||||||
|
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
|
||||||
|
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
|
||||||
|
INLEVEL
|
||||||
|
if (!po)
|
||||||
|
return LUA_ErrInvalid(L, "polyobj_t");
|
||||||
|
if (!mo)
|
||||||
|
return LUA_ErrInvalid(L, "mobj_t");
|
||||||
|
lua_pushboolean(L, P_MobjInsidePolyobj(po, mo));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int polyobj_get(lua_State *L)
|
static int polyobj_get(lua_State *L)
|
||||||
{
|
{
|
||||||
polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
|
polyobj_t *polyobj = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
|
||||||
|
@ -57,6 +105,7 @@ static int polyobj_get(lua_State *L)
|
||||||
|
|
||||||
switch (field)
|
switch (field)
|
||||||
{
|
{
|
||||||
|
// properties
|
||||||
case polyobj_valid:
|
case polyobj_valid:
|
||||||
lua_pushboolean(L, true);
|
lua_pushboolean(L, true);
|
||||||
break;
|
break;
|
||||||
|
@ -87,6 +136,16 @@ static int polyobj_get(lua_State *L)
|
||||||
case polyobj_triggertag:
|
case polyobj_triggertag:
|
||||||
lua_pushinteger(L, polyobj->triggertag);
|
lua_pushinteger(L, polyobj->triggertag);
|
||||||
break;
|
break;
|
||||||
|
// special functions
|
||||||
|
case polyobj_pointInside:
|
||||||
|
lua_pushcfunction(L, lib_polyobj_PointInside);
|
||||||
|
break;
|
||||||
|
case polyobj_mobjTouching:
|
||||||
|
lua_pushcfunction(L, lib_polyobj_MobjTouching);
|
||||||
|
break;
|
||||||
|
case polyobj_mobjInside:
|
||||||
|
lua_pushcfunction(L, lib_polyobj_MobjInside);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue