Log In  

As of version 1.2, PICO-8 includes a command useful for debugging: printh("string") This command prints a string to the host operating system's console. You can put printh() calls in your code to examine events or state without cluttering the game screen with debugging information.

So how do you see the host operating system's console?

In Linux, you probably already run the "pico8" command from a terminal window. If you don't, locate where you put the "pico-8" directory, then run the pico8 command from a terminal window using its full path. For example:


In Mac OS X, instead of double-clicking the PICO-8 icon, open Terminal, then start PICO-8 with the following command, adjusting the path to match where you put the app. For example:


In Windows, instead of double-clicking the PICO-8 icon, open Command Prompt, then start PICO-8 with the following command:

"\Program Files (x86)\PICO-8\pico8.exe"

Note that with the Windows version, the prompt appears immediately (the process is forked). PICO-8 output will appear in this window anyway.

Try it out! With PICO-8 running from the console, type this at the PICO-8 prompt:


The message appears in the console window (not the PICO-8 window).

(Updated for 1.5.)

P#14887 2015-10-02 19:12 ( Edited 2017-02-02 19:59)

Printh doesn't work on Windows. Either log file is needed or something else.

P#14890 2015-10-02 20:26 ( Edited 2015-10-03 00:26)

Hi dddaaannn, looks like you worked out how to do it, and then didn't update your post properly. In one sentence you say "Someone help me out here" then in the next sentence you say "Try it out! The message appears in the console window" which is the behaviour you're after. So you got it working.

I came here because I wanted to get log output too, and running it from the command prompt works just as you described.

P#19313 2016-03-19 19:28 ( Edited 2016-03-19 23:28)
:: Scathe

In the meantime, I made a really simple debug script to output specific values from your code to your p8 program's display (not ideal, but it works better than trying to print values from a random location in code).

First, make a global called "dbg", and set it to nothing.

Then, at the bottom of your _draw() function, put this:


Then at the bottom of your program code, this:

function debug(x,y)

To use it from anywhere in your code, just do "dbg=[value you want to see]", and it'll print guaranteed (rather than guessing if your print([value]) will work depending if it's before or after your cls() is called). You can, of course, add more things to the debug function - in my case, I display memory and cpu usage in there as well as the dbg variable.

P#19320 2016-03-20 02:34 ( Edited 2016-03-20 06:35)

@Domarius: At v1.2 the Windows version didn't work. My intent was to say that it worked on OS X and Linux but not Windows. This appears to have been fixed in a subsequent update, so I updated the post. Thanks!

P#19352 2016-03-21 20:55 ( Edited 2016-03-22 00:55)

That reads better now :)

P#19429 2016-03-26 22:31 ( Edited 2016-03-27 02:31)

Note: the exe file may be "pico8.exe" and not "pico-8.exe", it won't launch if the hyphen is wrong

P#34070 2016-12-23 23:12 ( Edited 2016-12-24 04:12)

printh is working great for me on a Mac. Thanks!

P#36813 2017-01-28 13:25 ( Edited 2017-01-28 18:25)

Corrected the Windows binary name, it is pico8.exe.

P#36823 2017-01-28 17:01 ( Edited 2017-01-28 22:01)

As user Felice pointed out in another thread, printh() also outputs to the system's debug stream.

On Windows you can use for example Sysinternal's DebugView to view it.


P#36955 2017-01-31 03:40 ( Edited 2017-01-31 08:43)

thanks @TastyEnchilada! I set up a filter in there so it only shows stuff beginning with INFO, this will help my development time :)

P#37087 2017-02-02 14:59 ( Edited 2017-02-02 20:00)

how do i get a file in the directory

P#94463 2021-07-04 22:18
:: merwok

What do you mean by 'get' and by 'the directory'?

P#94478 2021-07-05 13:46

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2022-10-05 09:28:14 | 0.015s | Q:28