playdate->lua->pushSprite() does not return the correct value



playdate->lua->pushSprite() does not return the correct value.

The bug that newSprite() fails in C_API has not been fixed yet, so it is given from Lua side, but when I try to return it as a return value with pushSprite() from C_API, it stops with an error log.

Please check the reproduced project attached.

rake generate:simulator:debug build run

to start the simulator.

Best regards. (4.3 KB)

Many thanks for the clear demo! It turned out to be one of those simple bugs that's been hiding in there since day 1 because nobody's ever used the function. I assume it worked when I first implemented it, but then other code changed and it broke without anyone noticing. :frowning:

I have a fix in the queue now, but it's not high priority so I don't know when it'll show up in a public release. As for a workaround until then, you could avoid pushing sprites back and forth through the C API by keeping references to the sprites in a table on the Lua side, then the C code would push the table index back to Lua instead of the sprite itself. I'd be happy to put together a quick demo, just let me know!