Warn if Lua attempted access NOLUA consvar

And quote variable name.
This commit is contained in:
James R 2021-07-05 18:39:12 -07:00
parent 18cbc1e370
commit 14c5d2c916
2 changed files with 5 additions and 2 deletions

View file

@ -2364,7 +2364,10 @@ static boolean CV_Command(void)
return false; return false;
if (( com_flags & COM_SAFE ) && ( v->flags & CV_NOLUA )) 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 // perform a variable print or set
if (COM_Argc() == 1) if (COM_Argc() == 1)

View file

@ -433,7 +433,7 @@ static int CVarSetFunction
consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR); consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR);
if (cvar->flags & CV_NOLUA) 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)) switch (lua_type(L, 2))
{ {