From bd5446989132c92f44bc9c8384d8ce871f4cabcf Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 9 Feb 2026 10:39:46 -0600 Subject: [PATCH] test some stuff --- assets/minesweeper/CMakeLists.txt | 4 +- assets/palette/paletteMinesweeper.png | Bin 127 -> 168 bytes assets/scene/minesweeper.lua | 101 +++++++++++++++++++--- src/script/module/display/modulecolor.c | 3 +- src/script/module/display/moduletileset.c | 15 ++++ src/script/module/time/moduletime.c | 13 ++- tools/asset/process/image.py | 1 + 7 files changed, 115 insertions(+), 22 deletions(-) diff --git a/assets/minesweeper/CMakeLists.txt b/assets/minesweeper/CMakeLists.txt index 96e0af1..c98c82d 100644 --- a/assets/minesweeper/CMakeLists.txt +++ b/assets/minesweeper/CMakeLists.txt @@ -3,4 +3,6 @@ # This software is released under the MIT License. # https://opensource.org/licenses/MIT -add_asset(TILESET ui.png type=PALETTIZED tileWidth=8 tileHeight=8) \ No newline at end of file +add_asset(TILESET ui.png type=PALETTIZED tileWidth=8 tileHeight=8) +add_asset(TILESET cell.png type=PALETTIZED tileWidth=8 tileHeight=8) +add_asset(TILESET grid.png type=PALETTIZED tileWidth=8 tileHeight=8) \ No newline at end of file diff --git a/assets/palette/paletteMinesweeper.png b/assets/palette/paletteMinesweeper.png index 26bb086ae687379b2c60c8dea52498c85f02f2e3..71936304d05a4506181c731d097dba73911ee2db 100644 GIT binary patch literal 168 zcmeAS@N?(olHy`uVBq!ia0vp^ia^ZB!2~4lYX$HDseDft$B>FSj42GW|1(x@`7bD( zoc`|z-!8-7vS-e{Z=D?cRd3GhLr?skD9!HpeCEeF7e3wtyZ_c4_V~xUZtnb<-A4}{ zla=N-TYl)^#fz7cle3b;ZaN1nxpCv6mzSrf=ZhCF?CtHZ@T^Phf6Fjy79%6$i-o34 UUwBkCfL1ejy85}Sb4q9e06<7Y6#xJL literal 127 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~j!3HF+SL($BDK}3S$B>FS$tej5KmPy!U*G0` ze34|{CNYDUhmpr8-1tB3;r5^EZ2On`OMdE|XB3n4J*{AaX~K^luaState, "__tostring"); lua_pushcfunction(context->luaState, moduleColorToString); lua_settable(context->luaState, -3); - - lua_pop(context->luaState, 1); } + lua_pop(context->luaState, 1); lua_register(context->luaState, "color", moduleColorFuncColor); lua_register(context->luaState, "colorRainbow", moduleColorRainbow); diff --git a/src/script/module/display/moduletileset.c b/src/script/module/display/moduletileset.c index 9e7e732..5cd8542 100644 --- a/src/script/module/display/moduletileset.c +++ b/src/script/module/display/moduletileset.c @@ -46,6 +46,21 @@ int moduleTilesetIndex(lua_State *l) { } else if(stringCompare(key, "texture") == 0) { lua_pushstring(l, ts->image); return 1; + } else if(stringCompare(key, "tileWidth") == 0) { + lua_pushnumber(l, ts->tileWidth); + return 1; + } else if(stringCompare(key, "tileHeight") == 0) { + lua_pushnumber(l, ts->tileHeight); + return 1; + } else if(stringCompare(key, "tileCount") == 0) { + lua_pushnumber(l, ts->tileCount); + return 1; + } else if(stringCompare(key, "columns") == 0) { + lua_pushnumber(l, ts->columns); + return 1; + } else if(stringCompare(key, "rows") == 0) { + lua_pushnumber(l, ts->rows); + return 1; } lua_pushnil(l); diff --git a/src/script/module/time/moduletime.c b/src/script/module/time/moduletime.c index a813a73..9d666fa 100644 --- a/src/script/module/time/moduletime.c +++ b/src/script/module/time/moduletime.c @@ -13,21 +13,20 @@ void moduleTime(scriptcontext_t *ctx) { // Script structure if(luaL_newmetatable(ctx->luaState, "time_mt")) { - // Metatable is new, set __index - lua_pushstring(ctx->luaState, "__index"); lua_pushcfunction(ctx->luaState, moduleTimeIndex); - lua_settable(ctx->luaState, -3); + lua_setfield(ctx->luaState, -2, "__index"); } + lua_pop(ctx->luaState, 1); - // Global time struct - lua_pushlightuserdata(ctx->luaState, &TIME); + dusktime_t **ud = (dusktime_t**)lua_newuserdatauv( + ctx->luaState, sizeof(dusktime_t*), 0 + ); + *ud = &TIME; luaL_setmetatable(ctx->luaState, "time_mt"); lua_setglobal(ctx->luaState, "TIME"); } int moduleTimeIndex(lua_State *L) { - assertNotNull(L, "Lua state cannot be NULL."); - const char_t *key = lua_tostring(L, 2); assertStrLenMin(key, 1, "Key cannot be empty."); diff --git a/tools/asset/process/image.py b/tools/asset/process/image.py index 570527a..0daa917 100644 --- a/tools/asset/process/image.py +++ b/tools/asset/process/image.py @@ -45,6 +45,7 @@ def processPalettizedImage(asset): elif color[3] == 0 and palColor[3] == 0: break else: + print('Pallete {} does not contain color #{}'.format(p['paletteName'], '{:02x}{:02x}{:02x}{:02x}'.format(color[0], color[1], color[2], color[3]))) hasAllColors = False break if hasAllColors: