-setpal & getpal renamed to setcolor & getcolor

-setcolor & getcolor now use r, g & b instead of uint32
This commit is contained in:
2022-10-05 17:47:58 +02:00
parent a9f7d46afd
commit 8415841c5c
3 changed files with 18 additions and 12 deletions

22
lua.cpp
View File

@@ -57,16 +57,22 @@ extern "C" {
loadpal(str);
return 0;
}
static int cpp_setpal(lua_State *L) {
static int cpp_setcolor(lua_State *L) {
uint8_t index = luaL_checkinteger(L, 1);
uint8_t color = luaL_checkinteger(L, 2);
setpal(index, color);
uint8_t r = luaL_checkinteger(L, 2);
uint8_t g = luaL_checkinteger(L, 3);
uint8_t b = luaL_checkinteger(L, 4);
uint32_t color = (r<<16) + (g<<8) + b;
setcolor(index, color);
return 0;
}
static int cpp_getpal(lua_State *L) {
static int cpp_getcolor(lua_State *L) {
uint8_t index = luaL_checkinteger(L, 1);
lua_pushinteger(L, getpal(index));
return 1;
uint32_t color = getcolor(index);
lua_pushinteger(L, (color>>16)&0xff);
lua_pushinteger(L, (color>>8)&0xff);
lua_pushinteger(L, color&0xff);
return 3;
}
static int cpp_settrans(lua_State *L) {
uint8_t index = luaL_checkinteger(L, 1);
@@ -613,8 +619,8 @@ void push_lua_funcs() {
lua_pushcfunction(L,cpp_color); lua_setglobal(L, "color");
lua_pushcfunction(L,cpp_loadpal); lua_setglobal(L, "loadpal");
lua_pushcfunction(L,cpp_setpal); lua_setglobal(L, "setpal");
lua_pushcfunction(L,cpp_getpal); lua_setglobal(L, "getpal");
lua_pushcfunction(L,cpp_setcolor); lua_setglobal(L, "setcolor");
lua_pushcfunction(L,cpp_getcolor); lua_setglobal(L, "getcolor");
lua_pushcfunction(L,cpp_settrans); lua_setglobal(L, "settrans");
lua_pushcfunction(L,cpp_gettrans); lua_setglobal(L, "gettrans");