From dd50bf6f258bfc1cf75d4b8803c5f3a25e2b8ccc Mon Sep 17 00:00:00 2001
From: Lactozilla <jp6781615@gmail.com>
Date: Sat, 15 Feb 2025 15:54:00 -0300
Subject: [PATCH] Add defaulthubmap, currenthubmap, hubmapenabled to Lua

---
 src/lua_script.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/lua_script.c b/src/lua_script.c
index 686555a16d..15db1b0a67 100644
--- a/src/lua_script.c
+++ b/src/lua_script.c
@@ -180,6 +180,25 @@ int LUA_PushGlobals(lua_State *L, const char *word)
 	} else if (fastcmp(word,"stoppedclock")) {
 		lua_pushboolean(L, stoppedclock);
 		return 1;
+	} else if (fastcmp(word,"defaulthubmap")) {
+		if (defaulthubmap == 0) {
+			lua_pushnil(L);
+		}
+		else {
+			lua_pushinteger(L, defaulthubmap);
+		}
+		return 1;
+	} else if (fastcmp(word, "currenthubmap")) {
+		if (currenthubmap == 0) {
+			lua_pushnil(L);
+		}
+		else {
+			lua_pushinteger(L, currenthubmap);
+		}
+		return 1;
+	} else if (fastcmp(word, "hubmapenabled")) {
+		lua_pushboolean(L, !hubmapdisabled);
+		return 1;
 	} else if (fastcmp(word,"netgame")) {
 		lua_pushboolean(L, netgame);
 		return 1;
@@ -444,7 +463,22 @@ int LUA_PushGlobals(lua_State *L, const char *word)
 // See the above.
 int LUA_CheckGlobals(lua_State *L, const char *word)
 {
-	if (fastcmp(word, "redscore"))
+	if (fastcmp(word, "currenthubmap")) {
+		if (lua_isnoneornil(L, 2)) {
+			currenthubmap = 0;
+		}
+		else {
+			int mapnum = luaL_checkinteger(L, 2);
+			if (mapnum < 1 || mapnum > NUMMAPS) {
+				luaL_error(L, "map number %d out of range (1 - %d)", mapnum, NUMMAPS);
+				return 1;
+			}
+			currenthubmap = (INT16)mapnum;
+		}
+	}
+	else if (fastcmp(word, "hubmapenabled"))
+		hubmapdisabled = !luaL_checkboolean(L, 2);
+	else if (fastcmp(word, "redscore"))
 		redscore = (UINT32)luaL_checkinteger(L, 2);
 	else if (fastcmp(word, "bluescore"))
 		bluescore = (UINT32)luaL_checkinteger(L, 2);
-- 
GitLab