From 6ac3d623215ea3d80b79165852b3ba6940fd21ac Mon Sep 17 00:00:00 2001
From: GoldenTails <milestailsprower101n2@gmail.com>
Date: Sun, 19 Apr 2020 20:01:29 -0500
Subject: [PATCH] Expose P_RingXYMovement to Lua.

Ever wanted to move like a ring horizontally?
---
 src/lua_baselib.c | 12 ++++++++++++
 src/p_mobj.c      |  2 +-
 src/p_mobj.h      |  1 +
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/lua_baselib.c b/src/lua_baselib.c
index 2cfc251ff..58c7c80a3 100644
--- a/src/lua_baselib.c
+++ b/src/lua_baselib.c
@@ -924,6 +924,17 @@ static int lib_pXYMovement(lua_State *L)
 	return 0;
 }
 
+static int lib_pRingXYMovement(lua_State *L)
+{
+	mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
+	NOHUD
+	INLEVEL
+	if (!actor)
+		return LUA_ErrInvalid(L, "mobj_t");
+	P_RingXYMovement(actor);
+	return 0;
+}
+
 // P_USER
 ////////////
 
@@ -3283,6 +3294,7 @@ static luaL_Reg lib[] = {
 	{"P_MaceRotate",lib_pMaceRotate},
 	{"P_RailThinker",lib_pRailThinker},
 	{"P_XYMovement",lib_pXYMovement},
+	{"P_RingXYMovement",lib_pRingXYMovement},
 
 	// p_user
 	{"P_GetPlayerHeight",lib_pGetPlayerHeight},
diff --git a/src/p_mobj.c b/src/p_mobj.c
index c26308a59..9d6efd950 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -2102,7 +2102,7 @@ void P_XYMovement(mobj_t *mo)
 	P_XYFriction(mo, oldx, oldy);
 }
 
-static void P_RingXYMovement(mobj_t *mo)
+void P_RingXYMovement(mobj_t *mo)
 {
 	I_Assert(mo != NULL);
 	I_Assert(!P_MobjWasRemoved(mo));
diff --git a/src/p_mobj.h b/src/p_mobj.h
index c94dbd650..d874ffe09 100644
--- a/src/p_mobj.h
+++ b/src/p_mobj.h
@@ -471,6 +471,7 @@ void P_NullPrecipThinker(precipmobj_t *mobj);
 void P_RemovePrecipMobj(precipmobj_t *mobj);
 void P_SetScale(mobj_t *mobj, fixed_t newscale);
 void P_XYMovement(mobj_t *mo);
+void P_RingXYMovement(mobj_t *mo);
 void P_EmeraldManager(void);
 
 extern INT32 modulothing;
-- 
GitLab