add pxl8.get_title() API to expose cart title to Lua

This commit is contained in:
asrael 2025-12-07 15:52:54 -06:00
parent db82efe269
commit 99d9c43ea3
No known key found for this signature in database
GPG key ID: 2786557804DFAE24
9 changed files with 75 additions and 22 deletions

View file

@ -66,7 +66,7 @@ static int pxl8_cart_loader(lua_State* L) {
static int pxl8_cart_searcher(lua_State* L) {
const char* modname = luaL_checkstring(L, 1);
pxl8_cart* cart = pxl8_cart_current();
pxl8_cart* cart = pxl8_get_cart();
if (!cart || !pxl8_cart_is_packed(cart)) {
lua_pushstring(L, "\n\tno packed cart mounted");
return 1;
@ -212,6 +212,9 @@ static const char* pxl8_ffi_cdefs =
"void pxl8_set_relative_mouse_mode(pxl8* sys, bool enabled);\n"
"void pxl8_set_running(pxl8* sys, bool running);\n"
"void pxl8_lua_log(int level, const char* file, int line, const char* msg);\n"
"typedef struct pxl8_cart pxl8_cart;\n"
"pxl8_cart* pxl8_get_cart(void);\n"
"const char* pxl8_cart_get_title(const pxl8_cart* cart);\n"
"typedef u32 pxl8_tile;\n"
"typedef struct pxl8_tilemap pxl8_tilemap;\n"
"typedef struct pxl8_tilesheet pxl8_tilesheet;\n"
@ -736,7 +739,7 @@ pxl8_result pxl8_script_run_fennel_file(pxl8_script* script, const char* filenam
return PXL8_ERROR_SCRIPT_ERROR;
}
pxl8_cart* cart = pxl8_cart_current();
pxl8_cart* cart = pxl8_get_cart();
pxl8_result result = PXL8_OK;
if (cart && pxl8_cart_is_packed(cart)) {