mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-16 09:02:06 +00:00
Merge branch 'texnamefornum' into 'next'
Add R_TextureNameForNum and R_CheckTextureNameForNum See merge request STJr/SRB2!1880
This commit is contained in:
commit
08c6e76d1c
3 changed files with 51 additions and 0 deletions
|
@ -2846,6 +2846,22 @@ static int lib_rTextureNumForName(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int lib_rCheckTextureNameForNum(lua_State *L)
|
||||
{
|
||||
INT32 num = (INT32)luaL_checkinteger(L, 1);
|
||||
//HUDSAFE
|
||||
lua_pushstring(L, R_CheckTextureNameForNum(num));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_rTextureNameForNum(lua_State *L)
|
||||
{
|
||||
INT32 num = (INT32)luaL_checkinteger(L, 1);
|
||||
//HUDSAFE
|
||||
lua_pushstring(L, R_TextureNameForNum(num));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// R_DRAW
|
||||
////////////
|
||||
static int lib_rGetColorByName(lua_State *L)
|
||||
|
@ -4203,6 +4219,8 @@ static luaL_Reg lib[] = {
|
|||
// r_data
|
||||
{"R_CheckTextureNumForName",lib_rCheckTextureNumForName},
|
||||
{"R_TextureNumForName",lib_rTextureNumForName},
|
||||
{"R_CheckTextureNameForNum", lib_rCheckTextureNameForNum},
|
||||
{"R_TextureNameForNum", lib_rTextureNameForNum},
|
||||
|
||||
// r_draw
|
||||
{"R_GetColorByName", lib_rGetColorByName},
|
||||
|
|
|
@ -1662,6 +1662,35 @@ INT32 R_CheckTextureNumForName(const char *name)
|
|||
return -1;
|
||||
}
|
||||
|
||||
//
|
||||
// R_CheckTextureNameForNum
|
||||
//
|
||||
// because sidedefs use numbers and sometimes you want names
|
||||
// returns no texture marker if no texture was found
|
||||
//
|
||||
const char *R_CheckTextureNameForNum(INT32 num)
|
||||
{
|
||||
if (num > 0 && num < numtextures)
|
||||
return textures[num]->name;
|
||||
|
||||
return "-";
|
||||
}
|
||||
|
||||
//
|
||||
// R_TextureNameForNum
|
||||
//
|
||||
// calls R_CheckTextureNameForNum and returns REDWALL if result is a no texture marker
|
||||
//
|
||||
const char *R_TextureNameForNum(INT32 num)
|
||||
{
|
||||
const char *result = R_CheckTextureNameForNum(num);
|
||||
|
||||
if (strcmp(result, "-") == 0)
|
||||
return "REDWALL";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// R_TextureNumForName
|
||||
//
|
||||
|
|
|
@ -104,6 +104,10 @@ INT32 R_TextureNumForName(const char *name);
|
|||
INT32 R_CheckTextureNumForName(const char *name);
|
||||
lumpnum_t R_GetFlatNumForName(const char *name);
|
||||
|
||||
// Returns the texture name for the texture number (in case you ever needed it)
|
||||
const char *R_CheckTextureNameForNum(INT32 num);
|
||||
const char *R_TextureNameForNum(INT32 num);
|
||||
|
||||
extern INT32 numtextures;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue