How can I set file:vbuf to "no" on simulator?

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?

Thanks ins advance for your help.

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.

Thanks for the help @outgunned .
The ":" on my post was a typo, I actually have it with just the period in my code

io.stdout:setvbuf("no")

and with that I'm getting the error

attempt to index a nil value (global 'io')

So for some reason it is not recognizing the "io" global :thinking:

1 Like

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.

2 Likes

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. :smiley:

This is the actual issue: Help with error e0 - #6 by optimusdag

Cheers!