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

@ -18,8 +18,9 @@ core.init(_pxl8_gfx, _pxl8_input, _pxl8_sys)
local pxl8 = {}
pxl8.get_fps = core.get_fps
pxl8.get_width = core.get_width
pxl8.get_height = core.get_height
pxl8.get_title = core.get_title
pxl8.get_width = core.get_width
pxl8.info = core.info
pxl8.warn = core.warn
pxl8.error = core.error

View file

@ -21,6 +21,17 @@ function core.get_height()
return C.pxl8_gfx_get_height(core.gfx)
end
function core.get_title()
local cart = C.pxl8_get_cart()
if cart ~= nil then
local title = C.pxl8_cart_get_title(cart)
if title ~= nil then
return ffi.string(title)
end
end
return "pxl8"
end
local function is_user_script(info)
local src = info and info.short_src
return src and (src:match("%.fnl$") or src:match("%.lua$"))