# Code

The **Code** view puts the game's files in the middle of the window and the live game
beside them. Whoever writes the script, you or an agent, a save reaches the running game
and you watch what it does.

![The Code view: the game's files by kind at the left, a Luau script in the middle, and the live game with the conversation at the right](../files/editor/img/code.jpg)

## Read a script beside the game

1. Press **Code** in the title bar.
2. Double-press a file in the left column. The files are listed by what they are: the
   project file, then Scenes, Scripts, Libraries, Art, Sounds and Tests.
3. Look under the list: for the script in front it says what the script **reads** (keys,
   tuning numbers, parts' fields), **writes**, **plays** and **keeps**. Press a row to go
   to its line.

**How you know it worked.** The script is in the middle, the game is still running at the
right, and the **Tests** row says how many of the game's tests pass.

## Change a script and see it

1. Change a line.
2. Save.

**How you know it worked.** The line under the text says **Reloaded at step 412. The game
kept running.**, and the game beside it behaves the new way. If the script does not
compile, the line says it **did not load** and the game runs the one before.

A change to the project file or a scene loads the game again from its files.

## Make a new script

1. Press **+** and choose **New script…**.
2. Type a name (lowercase letters, digits and `_`) and choose **Empty** or **With step
   and on_scene**.

**How you know it worked.** The script opens, it is listed under Scripts, and the game has
loaded again running it. `⌘Z` takes it back while the file is still as it was written.

## Read the problems

1. Press **Problems** in the dock.
2. Press a row to open its line.

**How you know it worked.** The dock's line reads **No problems**. The engine checks the
game's files when the game starts and after any file changes, so the list is always about
the files as they are on disk. A failing test is a row there too.

## See what an agent changed

1. Press the **Changed** tab over the list of files: only files on trial are listed.
2. Open one. The lines on trial are marked in the text, and the tab's head steps through
   them.

**How you know it worked.** A marked line says **on trial: the game is running the new
line**. Keep it or put it back there, or decide in the game: see
[Working with agents](agents.md#a-change-on-trial).

## Help while you type

- **Luau.** Completion, hover, call parameters and go to declaration, from the engine's
  own reference, so what is offered matches the engine you run. It knows the engine's API
  and your game's components; it does not know the types of your own values.
- **C#.** The editor opens, colours and saves `.cs` files and lists the engine's compile
  errors in **Problems**. It brings no C# language server; one you install from
  **Settings › Language Servers** adds completion. A game in C# needs an engine built with
  C# and the .NET SDK: see [Gameplay in C#](../guides/csharp.md) and
  [Troubleshooting](troubleshooting.md#a-game-in-c-does-not-play).

The scripting API itself is in the [reference](../reference/scripts.md).
