mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 15:32:33 +00:00
New Lua functions: R_GetColorByName and R_GetNameByColor
This commit is contained in:
parent
2b615aa09c
commit
2b678aaef0
1 changed files with 24 additions and 1 deletions
|
@ -20,6 +20,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "z_zone.h"
|
#include "z_zone.h"
|
||||||
#include "r_main.h"
|
#include "r_main.h"
|
||||||
|
#include "r_draw.h"
|
||||||
#include "r_things.h"
|
#include "r_things.h"
|
||||||
#include "m_random.h"
|
#include "m_random.h"
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
|
@ -2313,8 +2314,26 @@ static int lib_rTextureNumForName(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// S_SOUND
|
// R_DRAW
|
||||||
////////////
|
////////////
|
||||||
|
static int lib_rGetColorByName(lua_State *L)
|
||||||
|
{
|
||||||
|
const char* colorname = luaL_checkstring(L, 1);
|
||||||
|
//HUDSAFE
|
||||||
|
lua_pushinteger(L, R_GetColorByName(colorname));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lua exclusive function, returns the name of a color from the SKINCOLOR_ constant.
|
||||||
|
// SKINCOLOR_GREEN > "Green" for example
|
||||||
|
static int lib_rGetNameByColor(lua_State *L)
|
||||||
|
{
|
||||||
|
UINT8 colornum = (UINT8)luaL_checkinteger(L, 1);
|
||||||
|
if (!colornum || colornum >= MAXSKINCOLORS)
|
||||||
|
return luaL_error(L, "skincolor %d out of range (1 - %d).", colornum, MAXSKINCOLORS-1);
|
||||||
|
lua_pushstring(L, Color_Names[colornum]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int lib_sStartSound(lua_State *L)
|
static int lib_sStartSound(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -3153,6 +3172,10 @@ static luaL_Reg lib[] = {
|
||||||
{"R_CheckTextureNumForName",lib_rCheckTextureNumForName},
|
{"R_CheckTextureNumForName",lib_rCheckTextureNumForName},
|
||||||
{"R_TextureNumForName",lib_rTextureNumForName},
|
{"R_TextureNumForName",lib_rTextureNumForName},
|
||||||
|
|
||||||
|
// r_draw
|
||||||
|
{"R_GetColorByName", lib_rGetColorByName},
|
||||||
|
{"R_GetNameByColor", lib_rGetNameByColor},
|
||||||
|
|
||||||
// s_sound
|
// s_sound
|
||||||
{"S_StartSound",lib_sStartSound},
|
{"S_StartSound",lib_sStartSound},
|
||||||
{"S_StartSoundAtVolume",lib_sStartSoundAtVolume},
|
{"S_StartSoundAtVolume",lib_sStartSoundAtVolume},
|
||||||
|
|
Loading…
Reference in a new issue