Added the functions Polyobj_moveXY and Polyobj_rotate to Lua as polyobj.moveXY and polyobj.rotate
This commit is contained in:
parent
f86dad2979
commit
4ce161f9c3
|
@ -16,6 +16,10 @@
|
||||||
#include "p_polyobj.h"
|
#include "p_polyobj.h"
|
||||||
#include "lua_script.h"
|
#include "lua_script.h"
|
||||||
#include "lua_libs.h"
|
#include "lua_libs.h"
|
||||||
|
#include "lua_hud.h" // hud_running errors
|
||||||
|
|
||||||
|
#define NOHUD if (hud_running)\
|
||||||
|
return luaL_error(L, "HUD rendering code should not call this function!");
|
||||||
|
|
||||||
enum polyobj_e {
|
enum polyobj_e {
|
||||||
// properties
|
// properties
|
||||||
|
@ -29,10 +33,13 @@ enum polyobj_e {
|
||||||
polyobj_flags,
|
polyobj_flags,
|
||||||
polyobj_translucency,
|
polyobj_translucency,
|
||||||
polyobj_triggertag,
|
polyobj_triggertag,
|
||||||
// special functions
|
// special functions - utility
|
||||||
polyobj_pointInside,
|
polyobj_pointInside,
|
||||||
polyobj_mobjTouching,
|
polyobj_mobjTouching,
|
||||||
polyobj_mobjInside
|
polyobj_mobjInside,
|
||||||
|
// special functions - manipulation
|
||||||
|
polyobj_moveXY,
|
||||||
|
polyobj_rotate
|
||||||
};
|
};
|
||||||
static const char *const polyobj_opt[] = {
|
static const char *const polyobj_opt[] = {
|
||||||
// properties
|
// properties
|
||||||
|
@ -46,12 +53,16 @@ static const char *const polyobj_opt[] = {
|
||||||
"flags",
|
"flags",
|
||||||
"translucency",
|
"translucency",
|
||||||
"triggertag",
|
"triggertag",
|
||||||
// special functions
|
// special functions - utility
|
||||||
"pointInside",
|
"pointInside",
|
||||||
"mobjTouching",
|
"mobjTouching",
|
||||||
"mobjInside",
|
"mobjInside",
|
||||||
|
// special functions - manipulation
|
||||||
|
"moveXY",
|
||||||
|
"rotate",
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
|
// special functions - utility
|
||||||
static int lib_polyobj_PointInside(lua_State *L)
|
static int lib_polyobj_PointInside(lua_State *L)
|
||||||
{
|
{
|
||||||
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
|
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
|
||||||
|
@ -90,6 +101,35 @@ static int lib_polyobj_MobjInside(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special functions - manipulation
|
||||||
|
static int lib_polyobj_moveXY(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);
|
||||||
|
boolean checkmobjs = lua_opttrueboolean(L, 4);
|
||||||
|
NOHUD
|
||||||
|
INLEVEL
|
||||||
|
if (!po)
|
||||||
|
return LUA_ErrInvalid(L, "polyobj_t");
|
||||||
|
lua_pushboolean(L, Polyobj_moveXY(po, x, y, checkmobjs));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lib_polyobj_rotate(lua_State *L)
|
||||||
|
{
|
||||||
|
polyobj_t *po = *((polyobj_t **)luaL_checkudata(L, 1, META_POLYOBJ));
|
||||||
|
angle_t delta = luaL_checkangle(L, 2);
|
||||||
|
UINT8 turnthings = (UINT8)luaL_optinteger(L, 3, 0); // don't turn anything by default? (could change this if not desired)
|
||||||
|
boolean checkmobjs = lua_opttrueboolean(L, 4);
|
||||||
|
NOHUD
|
||||||
|
INLEVEL
|
||||||
|
if (!po)
|
||||||
|
return LUA_ErrInvalid(L, "polyobj_t");
|
||||||
|
lua_pushboolean(L, Polyobj_rotate(po, delta, turnthings, checkmobjs));
|
||||||
|
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));
|
||||||
|
@ -136,7 +176,7 @@ 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
|
// special functions - utility
|
||||||
case polyobj_pointInside:
|
case polyobj_pointInside:
|
||||||
lua_pushcfunction(L, lib_polyobj_PointInside);
|
lua_pushcfunction(L, lib_polyobj_PointInside);
|
||||||
break;
|
break;
|
||||||
|
@ -146,6 +186,13 @@ static int polyobj_get(lua_State *L)
|
||||||
case polyobj_mobjInside:
|
case polyobj_mobjInside:
|
||||||
lua_pushcfunction(L, lib_polyobj_MobjInside);
|
lua_pushcfunction(L, lib_polyobj_MobjInside);
|
||||||
break;
|
break;
|
||||||
|
// special functions - manipulation
|
||||||
|
case polyobj_moveXY:
|
||||||
|
lua_pushcfunction(L, lib_polyobj_moveXY);
|
||||||
|
break;
|
||||||
|
case polyobj_rotate:
|
||||||
|
lua_pushcfunction(L, lib_polyobj_rotate);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -976,7 +976,7 @@ static INT32 Polyobj_clipThings(polyobj_t *po, line_t *line)
|
||||||
|
|
||||||
|
|
||||||
// Moves a polyobject on the x-y plane.
|
// Moves a polyobject on the x-y plane.
|
||||||
static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y, boolean checkmobjs)
|
boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y, boolean checkmobjs)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
vertex_t vec;
|
vertex_t vec;
|
||||||
|
@ -1162,7 +1162,7 @@ static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rotates a polyobject around its start point.
|
// Rotates a polyobject around its start point.
|
||||||
static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings, boolean checkmobjs)
|
boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings, boolean checkmobjs)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
angle_t angle;
|
angle_t angle;
|
||||||
|
|
|
@ -336,6 +336,8 @@ typedef struct polyfadedata_s
|
||||||
// Functions
|
// Functions
|
||||||
//
|
//
|
||||||
|
|
||||||
|
boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y, boolean checkmobjs);
|
||||||
|
boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings, boolean checkmobjs);
|
||||||
polyobj_t *Polyobj_GetForNum(INT32 id);
|
polyobj_t *Polyobj_GetForNum(INT32 id);
|
||||||
void Polyobj_InitLevel(void);
|
void Polyobj_InitLevel(void);
|
||||||
void Polyobj_MoveOnLoad(polyobj_t *po, angle_t angle, fixed_t x, fixed_t y);
|
void Polyobj_MoveOnLoad(polyobj_t *po, angle_t angle, fixed_t x, fixed_t y);
|
||||||
|
|
Loading…
Reference in New Issue