diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index c8327658a64cf8b87f7ee281b266e85ef65c4e3e..b8833bf721980cbdd588dfd24c73cc35697fd29f 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -461,14 +461,12 @@ static int camera_set(lua_State *L) static int libd_patchExists(lua_State *L) { - HUDONLY lua_pushboolean(L, W_LumpExists(luaL_checkstring(L, 1))); return 1; } static int libd_cachePatch(lua_State *L) { - HUDONLY LUA_PushUserdata(L, W_CachePatchLongName(luaL_checkstring(L, 1), PU_PATCH), META_PATCH); return 1; } @@ -481,7 +479,6 @@ static int libd_getSpritePatch(lua_State *L) UINT8 angle = 0; spritedef_t *sprdef; spriteframe_t *sprframe; - HUDONLY if (lua_isnumber(L, 1)) // sprite number given, e.g. SPR_THOK { @@ -555,7 +552,6 @@ static int libd_getSprite2Patch(lua_State *L) spritedef_t *sprdef; spriteframe_t *sprframe; boolean super = false; // add SPR2F_SUPER to sprite2 if true - HUDONLY // get skin first! if (lua_isnumber(L, 1)) // find skin by number @@ -1135,8 +1131,6 @@ static int libd_getColormap(lua_State *L) UINT8* colormap = NULL; int translation_id = -1; - HUDONLY - if (lua_isnoneornil(L, 1)) ; // defaults to TC_DEFAULT else if (lua_type(L, 1) == LUA_TNUMBER) // skin number @@ -1178,7 +1172,7 @@ static int libd_getStringColormap(lua_State *L) { INT32 flags = luaL_checkinteger(L, 1); UINT8* colormap = NULL; - HUDONLY + colormap = V_GetStringColormap(flags & V_CHARCOLORMASK); if (colormap) { LUA_PushUserdata(L, colormap, META_COLORMAP); // push as META_COLORMAP userdata, specifically for patches to use! @@ -1264,21 +1258,18 @@ static int libd_fadeScreen(lua_State *L) static int libd_width(lua_State *L) { - HUDONLY lua_pushinteger(L, vid.width); // push screen width return 1; } static int libd_height(lua_State *L) { - HUDONLY lua_pushinteger(L, vid.height); // push screen height return 1; } static int libd_dup(lua_State *L) { - HUDONLY lua_pushinteger(L, vid.dup); // push integral scale (patch scale) lua_pushfixed(L, vid.fdup); // push fixed point scale (position scale) return 2; @@ -1286,7 +1277,6 @@ static int libd_dup(lua_State *L) static int libd_renderer(lua_State *L) { - HUDONLY switch (rendermode) { case render_opengl: lua_pushliteral(L, "opengl"); break; // OpenGL renderer case render_soft: lua_pushliteral(L, "software"); break; // Software renderer @@ -1300,14 +1290,12 @@ static int libd_renderer(lua_State *L) static int libd_RandomFixed(lua_State *L) { - HUDONLY lua_pushfixed(L, M_RandomFixed()); return 1; } static int libd_RandomByte(lua_State *L) { - HUDONLY lua_pushinteger(L, M_RandomByte()); return 1; } @@ -1316,7 +1304,6 @@ static int libd_RandomKey(lua_State *L) { INT32 a = (INT32)luaL_checkinteger(L, 1); - HUDONLY lua_pushinteger(L, M_RandomKey(a)); return 1; } @@ -1326,7 +1313,6 @@ static int libd_RandomRange(lua_State *L) INT32 a = (INT32)luaL_checkinteger(L, 1); INT32 b = (INT32)luaL_checkinteger(L, 2); - HUDONLY lua_pushinteger(L, M_RandomRange(a, b)); return 1; } @@ -1334,7 +1320,6 @@ static int libd_RandomRange(lua_State *L) // Macros. static int libd_SignedRandom(lua_State *L) { - HUDONLY lua_pushinteger(L, M_SignedRandom()); return 1; } @@ -1342,7 +1327,6 @@ static int libd_SignedRandom(lua_State *L) static int libd_RandomChance(lua_State *L) { fixed_t p = luaL_checkfixed(L, 1); - HUDONLY lua_pushboolean(L, M_RandomChance(p)); return 1; } @@ -1351,7 +1335,6 @@ static int libd_RandomChance(lua_State *L) // 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-st_translucency)*V_10TRANS); return 1; } @@ -1359,7 +1342,6 @@ static int libd_getlocaltransflag(lua_State *L) // Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int static int libd_getusertransflag(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; } @@ -1452,6 +1434,24 @@ static luaL_Reg lib_hud[] = { {"disable", lib_huddisable}, {"enabled", lib_hudenabled}, {"add", lib_hudadd}, + {"patchExists", libd_patchExists}, + {"cachePatch", libd_cachePatch}, + {"getSpritePatch", libd_getSpritePatch}, + {"getSprite2Patch", libd_getSprite2Patch}, + {"getColormap", libd_getColormap}, + {"getStringColormap", libd_getStringColormap}, + {"width", libd_width}, + {"height", libd_height}, + {"scale", libd_dup}, + {"renderer", libd_renderer}, + {"RandomFixed",libd_RandomFixed}, + {"RandomByte",libd_RandomByte}, + {"RandomKey",libd_RandomKey}, + {"RandomRange",libd_RandomRange}, + {"SignedRandom",libd_SignedRandom}, // MACRO + {"RandomChance",libd_RandomChance}, // MACRO + {"localTransFlag", libd_getlocaltransflag}, + {"userTransFlag", libd_getusertransflag}, {NULL, NULL} };