From 586fae05c4bce297fbde87da3409aaa3b762cc4c Mon Sep 17 00:00:00 2001
From: Steel Titanium <steeltitanium1@gmail.com>
Date: Thu, 19 Dec 2019 01:14:34 -0500
Subject: [PATCH] Allow access to bluescore and redscore

---
 src/dehacked.c   |  8 ++++++++
 src/lua_script.c | 11 +++++++++++
 2 files changed, 19 insertions(+)

diff --git a/src/dehacked.c b/src/dehacked.c
index 938699516..da787b57a 100644
--- a/src/dehacked.c
+++ b/src/dehacked.c
@@ -10479,6 +10479,12 @@ static inline int lib_getenum(lua_State *L)
 	} else if (fastcmp(word,"paused")) {
 		lua_pushboolean(L, paused);
 		return 1;
+	} else if (fastcmp(word,"bluescore")) {
+		lua_pushinteger(L, bluescore);
+		return 1;
+	} else if (fastcmp(word,"redscore")) {
+		lua_pushinteger(L, redscore);
+		return 1;
 	// begin map vars
 	} else if (fastcmp(word,"spstage_start")) {
 		lua_pushinteger(L, spstage_start);
@@ -10692,6 +10698,8 @@ static int lib_getActionName(lua_State *L)
 	return luaL_typerror(L, 1, "action userdata or Lua function");
 }
 
+
+
 int LUA_SOCLib(lua_State *L)
 {
 	lua_register(L,"freeslot",lib_freeslot);
diff --git a/src/lua_script.c b/src/lua_script.c
index fe3c2f10d..13592815b 100644
--- a/src/lua_script.c
+++ b/src/lua_script.c
@@ -106,6 +106,17 @@ static int noglobals(lua_State *L)
 		return 0;
 	}
 
+	if (fastcmp(csname,"redscore"))
+	{
+		redscore = (UINT32)luaL_checkinteger(L, 2);
+		return 0;
+	}
+	else if (fastcmp(csname,"bluescore"))
+	{
+		bluescore = (UINT32)luaL_checkinteger(L, 2);
+		return 0;
+	}
+
 	Z_Free(name);
 	return luaL_error(L, "Implicit global " LUA_QS " prevented. Create a local variable instead.", csname);
 }
-- 
GitLab