diff --git a/src/lua_baselib.c b/src/lua_baselib.c
index 9d65a583207055b35349dc64854888d845d9013b..ed29acc33c64ac018aa7146793f3daf7f5fdd9a0 100644
--- a/src/lua_baselib.c
+++ b/src/lua_baselib.c
@@ -214,15 +214,7 @@ static int lib_pRandomRange(lua_State *L)
 	return 1;
 }
 
-// Deprecated, macros, etc.
-static int lib_pRandom(lua_State *L)
-{
-	NOHUD
-	LUA_Deprecated(L, "P_Random", "P_RandomByte");
-	lua_pushinteger(L, P_RandomByte());
-	return 1;
-}
-
+// Macros.
 static int lib_pSignedRandom(lua_State *L)
 {
 	NOHUD
@@ -2481,7 +2473,6 @@ static luaL_Reg lib[] = {
 	{"P_RandomByte",lib_pRandomByte},
 	{"P_RandomKey",lib_pRandomKey},
 	{"P_RandomRange",lib_pRandomRange},
-	{"P_Random",lib_pRandom}, // DEPRECATED
 	{"P_SignedRandom",lib_pSignedRandom}, // MACRO
 	{"P_RandomChance",lib_pRandomChance}, // MACRO
 
diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c
index a709ba9f4f608a58534205f1a8d53f45e8e6ceaf..afc81c37d474092dcf1d312da504b0ae4fd64312 100644
--- a/src/lua_hudlib.c
+++ b/src/lua_hudlib.c
@@ -20,6 +20,7 @@
 #include "i_video.h" // rendermode
 #include "p_local.h" // camera_t
 #include "screen.h" // screen width/height
+#include "m_random.h" // m_random
 #include "v_video.h"
 #include "w_wad.h"
 #include "z_zone.h"
@@ -752,20 +753,92 @@ static int libd_renderer(lua_State *L)
 	return 1;
 }
 
+// M_RANDOM
+//////////////
+
+static int libd_RandomFixed(lua_State *L)
+{
+	HUDONLY
+	lua_pushfixed(L, M_RandomFixed());
+	return 1;
+}
+
+static int libd_RandomByte(lua_State *L)
+{
+	HUDONLY
+	lua_pushinteger(L, M_RandomByte());
+	return 1;
+}
+
+static int libd_RandomKey(lua_State *L)
+{
+	INT32 a = (INT32)luaL_checkinteger(L, 1);
+
+	HUDONLY
+	if (a > 65536)
+		LUA_UsageWarning(L, "v.RandomKey: range > 65536 is undefined behavior");
+	lua_pushinteger(L, M_RandomKey(a));
+	return 1;
+}
+
+static int libd_RandomRange(lua_State *L)
+{
+	INT32 a = (INT32)luaL_checkinteger(L, 1);
+	INT32 b = (INT32)luaL_checkinteger(L, 2);
+
+	HUDONLY
+	if (b < a) {
+		INT32 c = a;
+		a = b;
+		b = c;
+	}
+	if ((b-a+1) > 65536)
+		LUA_UsageWarning(L, "v.RandomRange: range > 65536 is undefined behavior");
+	lua_pushinteger(L, M_RandomRange(a, b));
+	return 1;
+}
+
+// Macros.
+static int libd_SignedRandom(lua_State *L)
+{
+	HUDONLY
+	lua_pushinteger(L, M_SignedRandom());
+	return 1;
+}
+
+static int libd_RandomChance(lua_State *L)
+{
+	fixed_t p = luaL_checkfixed(L, 1);
+	HUDONLY
+	lua_pushboolean(L, M_RandomChance(p));
+	return 1;
+}
+
 static luaL_Reg lib_draw[] = {
+	// cache
 	{"patchExists", libd_patchExists},
 	{"cachePatch", libd_cachePatch},
 	{"getSpritePatch", libd_getSpritePatch},
 	{"getSprite2Patch", libd_getSprite2Patch},
+	{"getColormap", libd_getColormap},
+	// drawing
 	{"draw", libd_draw},
 	{"drawScaled", libd_drawScaled},
 	{"drawNum", libd_drawNum},
 	{"drawPaddedNum", libd_drawPaddedNum},
 	{"drawFill", libd_drawFill},
 	{"drawString", libd_drawString},
-	{"stringWidth", libd_stringWidth},
-	{"getColormap", libd_getColormap},
 	{"fadeScreen", libd_fadeScreen},
+	// misc
+	{"stringWidth", libd_stringWidth},
+	// m_random
+	{"RandomFixed",libd_RandomFixed},
+	{"RandomByte",libd_RandomByte},
+	{"RandomKey",libd_RandomKey},
+	{"RandomRange",libd_RandomRange},
+	{"SignedRandom",libd_SignedRandom}, // MACRO
+	{"RandomChance",libd_RandomChance}, // MACRO
+	// properties
 	{"width", libd_width},
 	{"height", libd_height},
 	{"dupx", libd_dupx},