# Scene editing

You change a scene in the running game: pick a thing in the picture, change it, and the
game has the change at once. The editor writes the same change into the scene's file for
you. Most of the time an agent does this; this page is for when your hand is quicker.

![A thing picked in a 2D game: its outline and handles in the picture, its row in Things, and its parts and fields in the Inspector](../files/editor/img/scene.jpg)

## Pick a thing and change it

1. Pause the game and click the thing in the picture, or click its row in **Things**.
2. Drag it with **Move** (`M`), turn it with **Turn** (`T`), or size it with **Size**
   (`S`). The arrow keys move it a pixel; with `Shift`, ten.
3. Or change a value in the Inspector: type it, or drag across it.

**How you know it worked.** The thing is outlined with its name under it, and the game
shows the new value while you still hold the mouse. When you let go, the change is one
step on the timeline's own lane for your edits, and **Undo** in the title bar names it.

- `Esc` picks nothing. `F` brings the picked thing to the middle of the view.
- A thing that draws nothing (a trigger, a spawn point) is reached by turning on **Unseen**
  in the eye's menu.
- With **Snap to the tiles** on (it is at first), a moved thing's edge goes to a tile's
  edge when it comes near, and a turn goes by 15 degrees.

## Add, duplicate and delete

1. Press **+** in the left column and choose **Add a thing**: an empty thing, a sprite of
   one of the game's pictures, or a copy of the picked thing. `Shift+A` adds an empty
   thing where the middle of the view is.
2. `⌘D` (`Ctrl+D`) duplicates the picked thing; `Backspace` deletes it.
3. **Add a part** at the bottom of the Inspector gives a thing a part it lacks.

**How you know it worked.** The new thing has a row in **Things** under a name no other
thing has, and it is picked. Each of these is one step of undo.

## Undo and redo

1. Press **Undo** (`⌘Z`, `Ctrl+Z`). It takes back the last step, whichever it was: a
   value, a deleted thing, an added part.
2. Press **Redo** (`⌘⇧Z`, `Ctrl+Shift+Z`) to put it back.

**How you know it worked.** The Undo button's tooltip names the step it would take back
next. Undoing a **Keep** or a **Not this one** asks first: the step is named in the dock,
and pressing again does it. While you type in a text file, `⌘Z` is that text's own undo.

## A thing a script makes

A thing made by a script while the game runs has no line in a scene, and the Inspector
says so: **made while the game ran**.

1. Change its values as usual. They are listed as **Values set by hand**, *only in the
   running game*.
2. Press **Ask the agent to keep it**. The agent is handed the values to write into the
   script.

**How you know it worked.** The values are in your message to the agent. Deleting such a
thing is refused, with the reason: it is made by a script, so change it there.

## Ask why it is like this

1. Open a field's menu in the Inspector and press **Why?**. Or choose the **Why?** tool
   (`W`) and press a pixel of the picture.
2. Read the answer: who wrote the value last (a line of the scene or of a script), since
   which step, and what it was before. For a pixel: what is drawn there, in front of what.
3. Press the line to open it, or **Watch** to give the value its own lane on the timeline.

**How you know it worked.** The answer names a file and a line you can open. See
[Debugging](debugging.md).

## Tune the game's numbers

With nothing picked, the Inspector shows the game itself: its **Tuning** numbers, its
window, its input, its physics.

1. Press `Esc` so nothing is picked.
2. Change a number under **Tuning**. The running game reads it from then on, with no
   reload.
3. When you like it, press **Write it**.

**How you know it worked.** Before **Write it**, the card marks the number and says what
the project file has. After it, the mark is gone, and the write is one step of undo.

## Paint tiles

1. In a 2D game, pick a tilemap and press **Paint tiles**. With no tilemap in the scene,
   **Paint a new map** makes one.
2. Pick a tile from the sheet's panel and paint: **Brush** `B`, **Erase** `E`, **Fill**
   `G`, **Rectangle** `U`; `[` and `]` size the brush.
3. Press `Esc` to stop.

**How you know it worked.** Each stroke is in the picture when you let go, and is one step
of undo.

## A 3D game

![A 3D game in the editor: a thing picked with its three arrows, the view's corner naming the eye the picture is drawn from, and the world's axes](../files/editor/img/scene-3d.jpg)

1. Pick a thing. **Move** shows three arrows, **Turn** three rings, **Size** three
   handles. Drag one, or press `X`, `Y` or `Z` to take it and use the arrow keys.
2. Press `O` and drag to orbit round the picked thing. `L` switches the handles between
   the world's axes and the thing's own.
3. Look from another eye: **Perspective** `5`, **Top** `7`, **Front** `1`, **Side** `3`.
   **The game's camera** `0` is what the player sees.

**How you know it worked.** The corner of the picture names the eye it is drawn from, and
the Inspector's Position, turn and Scale follow your drag. Looking from the editor's eye
changes nothing in the game.

### Time of day

1. Pick a sun. The Inspector shows **Time of day**.
2. Drag the hour. The sun's turn, colour and strength follow in the running game.
3. Press **Keep** to write it, or **Put back**.

**How you know it worked.** Until **Keep**, the card says it is a preview and nothing is
written. **Keep** is one step of undo.
