My game has several save slots, and when returning to the initial screen to pick a different slot and start fresh, I COULD do lots of manual cleanup... but what I really want is just to reboot the game again as if I had exited it.
(NOT delete all the saved data, just launch fresh.)
Can this be done (in Lua)?
To my knowledge, there is no straightforward function to relaunch a game.
You can call
playdate.file.run("main") to re-run the main script but the global variables will not be reset. If you initialised properly your variable in your scripts that should be fine but you miss an initialisation that might create some unexpected bugs.
In theory you can give a new global variable (the second parameter) but you need to copy all the essential global variables (like playdate, print, etc.) however I do not know if that will release properly the memory used.
I put in a feature request for a simple reboot (with choice of same game vs. just exiting to launcher). Occasionally useful.