mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Add v.getSectorColormap
This commit is contained in:
parent
5203133f72
commit
91395fcfc9
1 changed files with 40 additions and 0 deletions
|
@ -1156,6 +1156,45 @@ static int libd_getStringColormap(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int libd_getSectorColormap(lua_State *L)
|
||||
{
|
||||
boolean has_sector = false;
|
||||
sector_t *sector = NULL;
|
||||
if (!lua_isnoneornil(L, 1))
|
||||
{
|
||||
has_sector = true;
|
||||
sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR));
|
||||
}
|
||||
fixed_t x = luaL_checkfixed(L, 2);
|
||||
fixed_t y = luaL_checkfixed(L, 3);
|
||||
fixed_t z = luaL_checkfixed(L, 4);
|
||||
int lightlevel = luaL_optinteger(L, 5, 255);
|
||||
UINT8 *colormap = NULL;
|
||||
extracolormap_t *exc = NULL;
|
||||
|
||||
INLEVEL
|
||||
HUDONLY
|
||||
|
||||
if (has_sector && !sector)
|
||||
return LUA_ErrInvalid(L, "sector_t");
|
||||
|
||||
if (sector)
|
||||
exc = P_GetColormapFromSectorAt(sector, x, y, z);
|
||||
else
|
||||
exc = P_GetSectorColormapAt(x, y, z);
|
||||
|
||||
if (exc)
|
||||
colormap = exc->colormap;
|
||||
else
|
||||
colormap = colormaps;
|
||||
|
||||
lightlevel = 255 - min(max(lightlevel, 0), 255);
|
||||
lightlevel >>= 3;
|
||||
|
||||
LUA_PushUserdata(L, colormap + (lightlevel * 256), META_COLORMAP);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int libd_fadeScreen(lua_State *L)
|
||||
{
|
||||
huddrawlist_h list;
|
||||
|
@ -1302,6 +1341,7 @@ static luaL_Reg lib_draw[] = {
|
|||
{"getSprite2Patch", libd_getSprite2Patch},
|
||||
{"getColormap", libd_getColormap},
|
||||
{"getStringColormap", libd_getStringColormap},
|
||||
{"getSectorColormap", libd_getSectorColormap},
|
||||
// drawing
|
||||
{"draw", libd_draw},
|
||||
{"drawScaled", libd_drawScaled},
|
||||
|
|
Loading…
Reference in a new issue