From 76c4f5dd5cd53b99a78ca3e342a8102784c88e40 Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Sat, 18 Aug 2018 14:18:58 -0400
Subject: [PATCH] Lua for I_GetMusicLength

---
 src/lua_baselib.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/lua_baselib.c b/src/lua_baselib.c
index d6aeb9a317..1f88be24ef 100644
--- a/src/lua_baselib.c
+++ b/src/lua_baselib.c
@@ -2266,9 +2266,16 @@ static int lib_sSpeedMusic(lua_State *L)
 }
 
 #ifdef HAVE_LUA_MUSICPLUS
+static int lib_sGetMusicLength(lua_State *L)
+{
+	NOHUD
+	lua_pushinteger(L, (UINT32)S_GetMusicLength());
+	return 1;
+}
+
 static int lib_sSetMusicPosition(lua_State *L)
 {
-	UINT32 position = 0;
+	UINT32 position = (UINT32)luaL_checkinteger(L, 1);
 	player_t *player = NULL;
 	NOHUD
 	if (!lua_isnone(L, 2) && lua_isuserdata(L, 2))
@@ -2850,6 +2857,7 @@ static luaL_Reg lib[] = {
 	{"S_ChangeMusic",lib_sChangeMusic},
 	{"S_SpeedMusic",lib_sSpeedMusic},
 #ifdef HAVE_LUA_MUSICPLUS
+	{"S_GetMusicLength",lib_sGetMusicLength},
 	{"S_SetMusicPosition",lib_sSetMusicPosition},
 	{"S_GetMusicPosition",lib_sGetMusicPosition},
 	{"S_PauseMusic",lib_sPauseMusic},
-- 
GitLab