From 2e5608d33b5d55ec3223afabbbe6486921d9707d Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 10 Mar 2020 12:57:30 +0100 Subject: [PATCH] Push race countdowns and functions to set them --- src/dehacked.c | 12 ++++++------ src/lua_baselib.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index e3e5bd74..d6d54b6f 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9891,18 +9891,12 @@ static inline int lib_getenum(lua_State *L) return 0; LUA_PushUserdata(L, &players[adminplayers[0]], META_PLAYER); return 1;*/ - } else if (fastcmp(word,"emeralds")) { - lua_pushinteger(L, emeralds); - return 1; } else if (fastcmp(word,"gravity")) { lua_pushinteger(L, gravity); return 1; } else if (fastcmp(word,"VERSIONSTRING")) { lua_pushstring(L, VERSIONSTRING); return 1; - } else if (fastcmp(word, "token")) { - lua_pushinteger(L, token); - return 1; } else if (fastcmp(word,"gamespeed")) { lua_pushinteger(L, gamespeed); return 1; @@ -9936,6 +9930,12 @@ static inline int lib_getenum(lua_State *L) } else if (fastcmp(word,"numlaps")) { lua_pushinteger(L, cv_numlaps.value); return 1; + } else if (fastcmp(word,"racecountdown")) { + lua_pushinteger(L, countdown); + return 1; + } else if (fastcmp(word,"exitcountdown")) { + lua_pushinteger(L, countdown2); // This name is pretty dumb. Hence why we'll prefer more descriptive names at least in Lua... + return 1; } return 0; } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6700d5af..672b4574 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -2641,6 +2641,41 @@ static int lib_kGetItemPatch(lua_State *L) return 1; } +// sets the remaining time before players blow up +static int lib_kSetRaceCountdown(lua_State *L) +{ + tic_t c = (tic_t)luaL_checkinteger(L, 1); + countdown = c; + return 0; +} + +// sets the remaining time before the race ends after everyone finishes +static int lib_kSetExitCountdown(lua_State *L) +{ + tic_t c = (tic_t)luaL_checkinteger(L, 1); + NOHUD + countdown2 = c; + return 0; +} + +// Sets the item cooldown before another shrink / SPB can be rolled +static int lib_kSetIndirectItemCountdown(lua_State *L) +{ + tic_t c = (tic_t)luaL_checkinteger(L, 1); + NOHUD + indirectitemcooldown = c; + return 0; +} + +// Sets the item cooldown before another shrink / SPB can be rolled +static int lib_kSetHyuCountdown(lua_State *L) +{ + tic_t c = (tic_t)luaL_checkinteger(L, 1); + NOHUD + hyubgone = c; + return 0; +} + static luaL_Reg lib[] = { {"print", lib_print}, {"chatprint", lib_chatprint}, @@ -2868,6 +2903,10 @@ static luaL_Reg lib[] = { {"K_GetKartAccel",lib_kGetKartAccel}, {"K_GetKartFlashing",lib_kGetKartFlashing}, {"K_GetItemPatch",lib_kGetItemPatch}, + {"K_SetRaceCountdown",lib_kSetRaceCountdown}, + {"K_SetExitCountdown",lib_kSetExitCountdown}, + {"K_SetIndirectItemCooldown",lib_kSetIndirectItemCountdown}, + {"K_SetHyudoroCooldown",lib_kSetHyuCountdown}, {NULL, NULL} };