PICO-8 Wiki
Advertisement
save [filename]
Saves the current cartridge to a file.
filename
The name of the cartridge file. If this is @clip, the cartridge data is copied to the system clipboard instead of saved to a file.

If the filename ends in .p8, the file will use the .p8 file format. This file includes the source code, sprites, map, sound effects, and music data.

If the filename ends in .p8.png, the file will use the .p8.png file format. The PNG image looks like a game cartridge, including a label with a screenshot and title.

If you use @clip as the filename, PICO-8 will save the contents of the cartridge to the system clipboard instead of to a file.

If the filename doesn't have an extension, PICO-8 will automatically add .p8.

Setting the label

When saving as a .p8.png file, PICO-8 generates a cartridge label. This label can include two lines of text and a screenshot image.

To set the text of the label, put two lines of comments at the top of the source code:

-- game title
-- by author name

To set the screenshot, run the game, then press F7 to take the current image. The label will use the most recent screenshot when you save the cartridge.

The compressed code size limit

PICO-8 uses compression to reduce the size of the source code when saving as a .p8.png file. The compressed code size must be under a certain limit (15,360 bytes) for the save to succeed. Use the info command to see how the code size compares to this limit. If you save to a .p8.png file and the compressed size exceeds the limit, PICO-8 prints an error message.

You can save and load a cartridge whose compressed code size exceeds the limit using a .p8 file. This allows you to save your program in progress before reducing its code size for publishing as a .p8.png, if necessary.

Saving to the system clipboard

You can save the contents of the cartridge to the system clipboard by specifying a filename of @clip:

> save @clip

The format of this value is designed to be pasted into a PICO-8 BBS message. It is delimited with [code]...[/code] and contains a hexadecimal representation of the cartridge. (This is *not* the same format as a .p8 file.) When you paste this into a BBS message, it is replaced with the cartridge running in the web player when the message is viewed.

Examples

At the PICO-8 prompt:

> save                 -- saves to the last file loaded or saved

> save mygame          -- saves to "mygame.p8"

> save mygame.p8       -- saves to "mygame.p8"

> save mygame.p8.png   -- saves to "mygame.p8.png" in image-encoded format

> save @clip           -- saves to clipboard in text-encoded format

See also

Advertisement