From 14c5d2c916e42c926dcf8267df3b49bd3dcab31d Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Mon, 5 Jul 2021 18:39:12 -0700
Subject: [PATCH] Warn if Lua attempted access NOLUA consvar

And quote variable name.
---
 src/command.c        | 5 ++++-
 src/lua_consolelib.c | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/command.c b/src/command.c
index 0e0b1a6853..e6c6587e8e 100644
--- a/src/command.c
+++ b/src/command.c
@@ -2364,7 +2364,10 @@ static boolean CV_Command(void)
 		return false;
 
 	if (( com_flags & COM_SAFE ) && ( v->flags & CV_NOLUA ))
-		return false;
+	{
+		CONS_Alert(CONS_WARNING, "Variable '%s' cannot be changed from Lua.\n", v->name);
+		return true;
+	}
 
 	// perform a variable print or set
 	if (COM_Argc() == 1)
diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c
index 414d9692a0..2b8cad69b8 100644
--- a/src/lua_consolelib.c
+++ b/src/lua_consolelib.c
@@ -433,7 +433,7 @@ static int CVarSetFunction
 	consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR);
 
 	if (cvar->flags & CV_NOLUA)
-		return luaL_error(L, "Variable %s cannot be set from Lua.", cvar->name);
+		return luaL_error(L, "Variable '%s' cannot be set from Lua.", cvar->name);
 
 	switch (lua_type(L, 2))
 	{
-- 
GitLab