From f418c6476f76d0b55adb8b7e71f95b2a4f2f7deb Mon Sep 17 00:00:00 2001
From: Eidolon <furyhunter600@gmail.com>
Date: Tue, 26 Apr 2022 13:47:35 -0500
Subject: [PATCH] Add drawerlib deltaTime function

---
 src/lua_hudlib.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c
index c7f2bbc28e..cffb0b64fc 100644
--- a/src/lua_hudlib.c
+++ b/src/lua_hudlib.c
@@ -1201,6 +1201,14 @@ static int libd_getusertransflag(lua_State *L)
 	return 1;
 }
 
+// Return the time elapsed for the previous frame, in tics.
+static int libd_deltaTime(lua_State *L)
+{
+	HUDONLY
+	lua_pushfixed(L, renderdeltatics);
+	return 1;
+}
+
 static luaL_Reg lib_draw[] = {
 	// cache
 	{"patchExists", libd_patchExists},
@@ -1242,6 +1250,7 @@ static luaL_Reg lib_draw[] = {
 	{"renderer", libd_renderer},
 	{"localTransFlag", libd_getlocaltransflag},
 	{"userTransFlag", libd_getusertransflag},
+	{"deltaTime", libd_deltaTime},
 	{NULL, NULL}
 };
 
-- 
GitLab