Using colormap[n] on colormap userdata from v.getColormap (e.g. colormap[0] or colormap[255]) now gives you the palette color replacing that index

This commit is contained in:
Monster Iestyn 2016-06-24 19:17:35 +01:00
parent 839db0122c
commit 88a805b331
1 changed files with 6 additions and 1 deletions

View File

@ -223,7 +223,12 @@ static int hudinfo_num(lua_State *L)
static int colormap_get(lua_State *L)
{
return luaL_error(L, "colormap is not a struct.");
const UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP));
UINT32 i = luaL_checkinteger(L, 2);
if (i >= 256)
return luaL_error(L, "colormap index %d out of range (0 - %d)", i, 255);
lua_pushinteger(L, colormap[i]);
return 1;
}
static int patch_get(lua_State *L)