diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 9e4eebeb08fd5b84b59c580f8221a1fa05b4b3f8..17d9a9cae7d58458063f6730ad90062c0f118d43 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3853,6 +3853,34 @@ static int lib_gAddGametype(lua_State *L) return 0; } +// Lua exclusive function to unlock Lua Conditions +// Up to Lua scripter +static int lib_gUnlockCondition(lua_State* L) +{ + int id = luaL_checkinteger(L, 1) - 1; + boolean global = luaL_checkboolean(L, 2); + + if (id <= 0 || id > MAXLUACONDITIONS) + { + luaL_error(L, "Lua condition %d out of range (1 - %d)", id + 1, MAXLUACONDITIONS); + return 0; + } + + if (global) + { + serverGamedata->lua[id] = true; + M_SilentUpdateUnlockablesAndEmblems(serverGamedata); + } + + clientGamedata->lua[id] = true; + if (M_UpdateUnlockablesAndExtraEmblems(clientGamedata)) + { + S_StartSound(NULL, sfx_s3k68); + } + + return 0; +} + // Bot adding function! // Partly lifted from Got_AddPlayer static int lib_gAddPlayer(lua_State *L) @@ -4600,6 +4628,7 @@ static luaL_Reg lib[] = { {"G_AddGametype", lib_gAddGametype}, {"G_AddPlayer", lib_gAddPlayer}, {"G_RemovePlayer", lib_gRemovePlayer}, + {"G_UnlockCondition", lib_gUnlockCondition}, {"G_SetUsedCheats", lib_gSetUsedCheats}, {"G_BuildMapName",lib_gBuildMapName}, {"G_BuildMapTitle",lib_gBuildMapTitle},