# The library

Find and run scripts other people shared, heart the ones you use, keep your own scripts, palettes and brushes, and publish scripts.

_Shortcuts are written for Windows and Linux. On a Mac, use ⌘ Cmd where they say Ctrl, and ⌥ Option for Alt._

Your **library** is the scripts, palettes and brushes you made, saved or forked. They live outside
any sprite, so you can use them in every sprite. The **script library** is the shared side:
scripts people have published, including the **Official** set made by pxstud.io. Palettes and
brushes aren't shared: the editor comes with a **Built-in** set of each, and the ones you save are
yours alone.

| | Yours | Shared or built in |
| - | - | - |
| Scripts | Scripts > Open My Script... | Scripts > Browse Script Library... |
| Palettes | The **My Palettes** tab of the Palette Library | Its **Built-in** tab |
| Brushes | The **My Brushes** tab of the Brush Library | Its **Built-in** tab |

Open the **Palette Library** with the library button at the top of the palette, and the **Brush
Library** with the **Custom brushes** button in the tool options of the Pencil and the
Eraser.

Your own items are stored in this browser and work offline, signed out. With Sync they're also
kept in your account and synced to your other devices. The built-in palettes and brushes are part
of the editor, so they work offline and signed out too.

## Browsing the script library

The script library needs a free account on pxstud.io: sign in with your email address and open
the link we send. A free account stores nothing in the cloud, and the rest of the editor never
needs one.

- **Search** by name or tag. Results update as you type.
- **Tags** in the sidebar narrow the list, with how many scripts use each. Pick up to 3; a script
  must have all of them. Clicking a tag on a card filters by it too, and **Clear filters** starts
  over.
- **All scripts** and **Official** choose between everything and just the Official scripts.

Results are ranked by how many people ran or forked each script, with each person counted once
(your own runs don't count). Your hearted scripts come first.

Each card shows the script's name, its author and version, an **Official** or **Yours** badge
(**edited** when your draft is newer than what's published), its tags, and how many people ran
and forked it. A card lists the latest published version. To use an older one, open
**Versions** and pick it from the **Version** list, which shows each version's date and release
note; the card's buttons then act on that version.

## Running and forking

| Button | Does |
| - | - |
| **Run** | Runs it on the current sprite, asking for its options first if it has any (an **Options** badge on the card says so). |
| **Fork** | Copies it into your library and opens it in the script panel, where you can change it. The copy keeps the credit to the original. |
| **View code** | Opens the code read-only, or in the script editor if it's yours. |

## Hearts

The heart on a card **hearts** a script: gray when it isn't hearted, red when it is. Hearted
scripts are listed first in every search, and are saved in this browser, so you can still list,
run and fork them **offline**: without a connection the script library shows just your hearted
scripts, and says so.

Your hearted scripts are also on your account page, on the **Hearted** shelf of the Scripts group
in its **Library** section. Right-click one there for **Fork to yours** or **Unheart**.

## Built-in palettes and brushes

The Palette Library's **Built-in** tab lists classic console palettes and popular ones from
[Lospec](https://lospec.com/palette-list), each credited to its author. **Use** replaces the
sprite's palette, **Append** adds its colors, and the save button saves a copy to My Palettes,
keeping the credit. **Find more on Lospec** opens Lospec's palette list; import one by name in My
Palettes. See [Color and palettes](https://pxstud.io/docs/manual/guides/color.md#the-palette-library).

The Brush Library's **Built-in** tab has a set of brush shapes. **Select** draws with one, and the
save button saves a copy to My Brushes.

## Custom brushes

The Brush Library's **My Brushes** tab has a small editor for making brushes:

1. Pick a grid size: **8×8**, **16×16**, **32×32** or **64×64**.
2. Click a cell to fill or empty it, or drag across cells to paint several. **Clear** empties the
   grid.
3. Name the brush and choose **Save to My Brushes**.

Click **Select** on a saved brush to draw with it. A custom brush always draws at its own size,
whatever the **Size** option says; pick one of the built-in shapes in the tool options to go
back. The pencil button renames a brush (type the name, then `Enter`; `Esc` cancels),
and the trash button deletes it from My Brushes, after asking. Deleting a palette from My
Palettes asks the same way.

## Your palettes and scripts

- **Palettes:** the My Palettes tab saves, loads, imports and exports palettes. See [Color and
  palettes](https://pxstud.io/docs/manual/guides/color.md#the-palette-library).
- **Scripts:** Scripts > New Script... starts one and Scripts > Open My Script... lists yours, with rename and
  delete. Scripts you opened recently are at the bottom of the Scripts menu. The scripting API is
  documented in the [scripting reference](https://pxstud.io/docs/scripting.md).

Your [account page](https://app.pxstud.io/account) (its **Library** section) also lists everything of yours, signed out too: right-click an
item (or press `Shift+F10`) to rename, duplicate, download or delete it.

## Publishing scripts

Publishing shares a script in the script library. Every script has a **draft**, the version you
edit, and **published versions**. Each time you publish, the draft becomes the next numbered
version, and published versions never change. Edits after that stay in your draft (marked
**edited**) until you publish again, so people using your script aren't affected by work in
progress.

Each script also has a **visibility**. Everything starts **Private**. A **shared** script is
listed in the script library from its first published version; a private one that you published
isn't listed. Scripts can have up to 3 tags (each up to 24 characters); while you type one,
matching tags already in use are suggested, with how many scripts use them.

In the script panel, the save button saves your draft and the publish button publishes it. The
**Private** or **Shared** badge beside the script's name (or the settings button) opens **Script
Settings**, with its tags, who can see it, and its version history, where you can read an older
version or **restore** it into your draft. The account page and the Open Script dialog use the
same badges: **Private**, **Shared v2**, or **Private v2** for a published script that's private.

Changing tags or visibility of a published script takes effect in the script library right away.
Deleting a published script takes it out of the script library too.

## Accounts

| | Without an account | Free account | With Sync |
| - | - | - | - |
| Built-in palettes and brushes | Yes | Yes | Yes |
| Your own library | In this browser | In this browser | Synced too |
| Browse, run, fork and heart scripts | No | Yes | Yes |
| Publish scripts | No | No | Yes |

A year of Sync comes with the desktop app ($20 once), which you get from your [account page](https://app.pxstud.io/account). Sync is optional, and it only renews if you turn on **Auto-renew**.

**When Sync ends**, your account stays a free one, your published, shared scripts stay in the script library, and you
can still unpublish or delete them. Your own items stay in your browsers. The cloud copy of
everything else (unpublished or private scripts, your palettes and brushes) is kept read-only for
180 days, then deleted from the server.
