From a0495142dfa0b9510079cc398eff90960f2561e8 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 30 Oct 2018 19:40:59 +0100 Subject: [PATCH 1/3] Small hud library additions --- src/lua_hudlib.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 60cbbe501..893534960 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -560,6 +560,15 @@ static int libd_renderer(lua_State *L) return 1; } +// 30/10/18 Lat': Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int +// Could as well be thrown in global vars for ease of access but I guess it makes sense for it to be a HUD fn +static int libd_getlocaltransflag(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, (10-cv_translucenthud.value)*V_10TRANS); // A bit weird that it's called "translucenthud" yet 10 is fully opaque :V + return 1; +} + static luaL_Reg lib_draw[] = { {"patchExists", libd_patchExists}, {"cachePatch", libd_cachePatch}, @@ -576,6 +585,7 @@ static luaL_Reg lib_draw[] = { {"dupx", libd_dupx}, {"dupy", libd_dupy}, {"renderer", libd_renderer}, + {"localTransFlag", libd_getlocaltransflag}, {NULL, NULL} }; @@ -599,6 +609,20 @@ static int lib_huddisable(lua_State *L) return 0; } +// 30/10/18: Lat': How come this wasn't here before? +static int lib_hudenabled(lua_State *L) +{ + enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); + lua_settop(L, 2); + if (!gL || hud_enabled[option/8] & (1<<(option%8))) + lua_pushboolean(L, true); + else + lua_pushboolean(L, false); + + return 1; +} + + // add a HUD element for rendering static int lib_hudadd(lua_State *L) { @@ -623,6 +647,7 @@ static int lib_hudadd(lua_State *L) static luaL_Reg lib_hud[] = { {"enable", lib_hudenable}, {"disable", lib_huddisable}, + {"enabled", lib_hudenabled}, {"add", lib_hudadd}, {NULL, NULL} }; From 799d8d2749250218bd557d09c9727df3658f7a9f Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 30 Oct 2018 22:29:28 +0100 Subject: [PATCH 2/3] remove gL check --- src/lua_hudlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 893534960..2ba6c8a60 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -614,7 +614,7 @@ static int lib_hudenabled(lua_State *L) { enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); lua_settop(L, 2); - if (!gL || hud_enabled[option/8] & (1<<(option%8))) + if (hud_enabled[option/8] & (1<<(option%8))) lua_pushboolean(L, true); else lua_pushboolean(L, false); From 68414585469fbb4e1c739253e9561b430dcaf0eb Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Tue, 30 Oct 2018 22:51:05 +0100 Subject: [PATCH 3/3] got rid of the settop as well --- src/lua_hudlib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 2ba6c8a60..bc9423bea 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -613,7 +613,6 @@ static int lib_huddisable(lua_State *L) static int lib_hudenabled(lua_State *L) { enum hud option = luaL_checkoption(L, 1, NULL, hud_disable_options); - lua_settop(L, 2); if (hud_enabled[option/8] & (1<<(option%8))) lua_pushboolean(L, true); else