mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 12:50:44 +00:00
Merge branch 'patch-lua-cv_registervar' into 'public_next'
Patch: Lua CV_RegisterVar See merge request !109
This commit is contained in:
commit
9b788b55f6
1 changed files with 9 additions and 0 deletions
|
@ -391,12 +391,21 @@ static int lib_cvRegisterVar(lua_State *L)
|
||||||
// stack: cvar table, cvar userdata
|
// stack: cvar table, cvar userdata
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, "CV_Vars");
|
lua_getfield(L, LUA_REGISTRYINDEX, "CV_Vars");
|
||||||
I_Assert(lua_istable(L, 3));
|
I_Assert(lua_istable(L, 3));
|
||||||
|
|
||||||
|
lua_getfield(L, 3, cvar->name);
|
||||||
|
if (lua_type(L, -1) != LUA_TNIL)
|
||||||
|
return luaL_error(L, M_GetText("Variable %s is already defined\n"), cvar->name);
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
lua_pushvalue(L, 2);
|
lua_pushvalue(L, 2);
|
||||||
lua_setfield(L, 3, cvar->name);
|
lua_setfield(L, 3, cvar->name);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
// actually time to register it to the console now! Finally!
|
// actually time to register it to the console now! Finally!
|
||||||
|
cvar->flags |= CV_MODIFIED;
|
||||||
CV_RegisterVar(cvar);
|
CV_RegisterVar(cvar);
|
||||||
|
if (cvar->flags & CV_MODIFIED)
|
||||||
|
return luaL_error(L, "failed to register cvar (probable conflict with internal variable/command names)");
|
||||||
|
|
||||||
// return cvar userdata
|
// return cvar userdata
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue