mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Make the colormap returned by v.getColormap() writable.
I mean it was already readable anyway...
This commit is contained in:
parent
0abc659168
commit
53ec972887
1 changed files with 14 additions and 1 deletions
|
|
@ -251,7 +251,7 @@ static int hudinfo_num(lua_State *L)
|
||||||
|
|
||||||
static int colormap_get(lua_State *L)
|
static int colormap_get(lua_State *L)
|
||||||
{
|
{
|
||||||
const UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP));
|
UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP));
|
||||||
UINT32 i = luaL_checkinteger(L, 2);
|
UINT32 i = luaL_checkinteger(L, 2);
|
||||||
if (i >= 256)
|
if (i >= 256)
|
||||||
return luaL_error(L, "colormap index %d out of range (0 - %d)", i, 255);
|
return luaL_error(L, "colormap index %d out of range (0 - %d)", i, 255);
|
||||||
|
|
@ -259,6 +259,16 @@ static int colormap_get(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int colormap_set(lua_State *L)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
colormap[i] = (UINT8)luaL_checkinteger(L, 3);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int patch_get(lua_State *L)
|
static int patch_get(lua_State *L)
|
||||||
{
|
{
|
||||||
patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH));
|
patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH));
|
||||||
|
|
@ -1331,6 +1341,9 @@ int LUA_HudLib(lua_State *L)
|
||||||
luaL_newmetatable(L, META_COLORMAP);
|
luaL_newmetatable(L, META_COLORMAP);
|
||||||
lua_pushcfunction(L, colormap_get);
|
lua_pushcfunction(L, colormap_get);
|
||||||
lua_setfield(L, -2, "__index");
|
lua_setfield(L, -2, "__index");
|
||||||
|
|
||||||
|
lua_pushcfunction(L, colormap_set);
|
||||||
|
lua_setfield(L, -2, "__newindex");
|
||||||
lua_pop(L,1);
|
lua_pop(L,1);
|
||||||
|
|
||||||
luaL_newmetatable(L, META_PATCH);
|
luaL_newmetatable(L, META_PATCH);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue