From 88a805b3313e6a47afa4423889254095c4091e04 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 24 Jun 2016 19:17:35 +0100 Subject: [PATCH] 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 --- src/lua_hudlib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 31549afa7..86784293e 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -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)