Hi.
I'm battling with a pretty obscure crash on my game and I want to be sure the print() output is displayed immediately with no buffer to be able to debug the crash before the simulator freezes.
I've tried using io:stdout:setvbuf("no") but I get an error attempt to index a nil value (global 'io')
Is there a way to ensure no buffer is used for the simulator's console output?
Not sure if stdout even works with Playdate SDK, but you probably wanted to call io.stdout:setvbuf("no") . : is shorthand for invoking a function with self as the first parameter.
If it helps, some of the Lua standard libraries aren't on the Playdate: the package, io and os libraries are completely removed, and the debug library is severely stripped down.
As for immediately flushing stdout, there's no good way to do that -- in Lua at least. In C you can call printf from within the Simulator dynamic library and it'll log to the Simulator's stdout -- but not the in-app console.
Thanks scratchminer.
I thought I had a buffer issue because I could see some expected outputs when my game crashed.
It turns out the crash was for some other reason so I'm not even sure there is a buffer for prints anymore.