# game.json, the library and the limits

Generated from the code that checks and enforces them. For the calls see `api.md`; for how-to pages see `guide.md`.

## game.json

Only `id`, `title`, `version` and `api` are needed. `earthgames check` tells you what is wrong in plain words.

| Field | Takes | Left out | What it is |
|---|---|---|---|
| `id` | 3 to 40 lowercase letters, digits or dashes | required | The game's name in links (`/games/<id>`). It is yours once you have submitted it, and it cannot change. |
| `title` | text, up to 60 characters | required | The name players see. |
| `summary` | text, up to 200 characters | empty (a warning) | One or two sentences players read before they join. |
| `version` | three numbers, like 1.0.0 | 0.1.0 | Raise it each time you submit. Players keep the approved version until the new one is approved. |
| `api` | 1 | required | The API version the game was written for. Additions to the API never change it. |
| `instance.kind` | "match" or "persistent" | "match" | A match is played and over. A persistent world keeps what it saves and can be opened again with the same invite code. |
| `instance.maxPlayers` | 1 to 32 | 8 | How many players one running game holds. |
| `instance.minPlayers` | 1 to maxPlayers | 1 | How many players the game is meant for at least. Shown to players; the game still starts with fewer. |
| `area` | exactly one of `{ "anywhere": true }`, `{ "bbox": [west, south, east, north] }`, `{ "regions": [...] }`, `{ "built": true }`, `{ "corridor": ... }` | { "anywhere": true } | Where the game can be played. Leave it out unless the game really needs one place: a game that plays anywhere can be started by anyone, where they are. |
| `content.violence` | "none", "mild" or "strong" | "none" | How violent the game is. Players see it before they enter. |
| `content.blood` | true or false | false | Whether the game has blood. Blood is drawn only when this is true, and only for signed-in players of 17 or older who turned it on in their own settings. Guests never see it. Needs a violence level other than "none". |
| `content.horror` | "none", "mild" or "strong" | "none" | How frightening the game is. |
| `content.language` | "none", "mild" or "strong" | "none" | How rough the game's own text is. |
| `content.pvp` | true or false | false | Whether players can hurt each other. |
| `content.notice` | text, up to 200 characters | empty | Anything else players should know before they enter, in your own words. |
| `world.traffic` | 0 to 2 | 0 | Everyday traffic inside your game: 0 is none, 1 is as in the shared world. |
| `world.pedestrians` | 0 to 2 | 0 | Everyday people on the streets inside your game, on the same scale. |
| `player.modes` | a list from "walk", "drive", "fly", "boat", "bike" | every mode | How players may get around in your game. |
| `player.rejoinS` | 0 to 600 (seconds) | 0 | How long a player's place is held when their connection drops. You hear `onPlayerAway`, then `onPlayerJoin` with `rejoined: true`, or `onPlayerLeave` when time runs out. |
| `actions` | a list of up to 12: { "id", "label", "key" } | none | Your own keys. `key` is "panel" (the game's main key, J) or one of the keys listed under Library below. A press fires `onUi` with `{ from: "action", id }`. |

## The library

### Zone and marker styles

`style` on `eg.entities.add`. Any other word gives the default.

`default` (white), `pickup` (amber), `dropoff` (green), `drop` (green), `depot` (light blue), `hot` (red), `lockup` (orange-red), `heal` (green), `armor` (blue), `weapon` (amber), `gun` (orange), `hint` (gray), `witness` (yellow), `crew` (purple), `respray` (sky blue), `safehouse` (lime), `race` (pink), `grid` (gold)

### Weapons

| Id | Name | Damage | Range (m) | Per second | Magazine | Most rounds carried |
|---|---|---|---|---|---|---|
| `fists` | Fists | 20 | 1.7 | 2.5 |  |  |
| `bat` | Bat | 50 | 2.1 | 1.6 |  |  |
| `pistol` | Pistol | 34 | 60 | 4 | 12 | 120 |
| `smg` | SMG | 18 | 45 | 11 | 30 | 240 |
| `shotgun` | Shotgun | 12 × 8 | 25 | 1.1 | 6 | 48 |

Everyone always has `fists`. Damage falls off with distance for guns. Any other lowercase id is an item of your own.

### Character behaviors

`brain` on a kind, a spawner, `eg.npcs.spawn` or `eg.npcs.setBrain`.

- `idle`: Stands where it is.
- `wander`: Walks around near where it started.
- `chase`: Goes after the nearest player it can see (or its target) and attacks when in reach.
- `flee`: Runs away from players.
- `guard`: Stays at its post (`home`) and goes for players who come within sight.
- `patrol`: Walks its `route`, point after point, and around again.
- `goto`: Walks to its `target`; you hear `onNpc` with ev "reached".

### A kind of character, left to itself

`scale: 1`, `speed: 1.4`, `runSpeed: 4.5`, `health: 100`, `sight: 40`, `leash: 90`, `brain: "idle"`, `aggro: true`. Speeds are meters per second, `sight` and `leash` (how far it follows) are meters.

### A spawner, left to itself

`radius: 8`, `count: 6`, `capNear: 12`, `capTotal: 60`, `perSecond: 2`, `respawnS: 0`, `minFromPlayersM: 40`, `maxFromPlayersM: 160`. These are for a spawner with no `at`; a placed one starts with `minFromPlayersM: 0`.

### Character models

`model` on a kind. Left out, every character gets a different one.

`female-a`, `female-b`, `female-c`, `female-d`, `female-e`, `female-f`, `male-a`, `male-b`, `male-c`, `male-d`, `male-e`, `male-f`, `male-g`, `worker`, `female-g`, `female-h`, `female-i`, `female-j`, `female-k`, `female-l`, `female-m`, `female-n`, `female-o`, `female-p`, `female-q`, `female-r`, `female-s`, `male-h`, `male-i`, `male-j`, `male-k`, `male-l`, `male-m`, `male-n`, `male-o`, `male-p`, `male-q`, `male-r`, `male-s`, `male-t`

### Sounds

`eg.audio.cue(player, id)`. An id that is not in the library plays the waypoint sound.

- `ui.click`: UI click
- `ui.open`: UI open
- `ui.chat`: Chat message
- `ui.mention`: Chat mention or whisper
- `ui.waypoint`: Waypoint set
- `ui.call`: Vehicle called
- `ui.garage.ping`: Garage signal ping
- `ui.rare`: Rare find sting
- `ui.error`: UI error
- `ui.job_offer`: Job board opened
- `ui.job_accept`: Job accepted
- `ui.job_load`: Cargo loaded
- `ui.job_deliver`: Delivery complete
- `ui.job_fail`: Job failed

### Keys for your own actions

`"panel"` (the game's main key, J), `KeyB`, `KeyG`, `KeyH`, `KeyJ`, `KeyK`, `KeyL`, `KeyN`, `KeyO`, `KeyP`, `KeyU`, `KeyY`, `KeyZ`, `Digit5`, `Digit6`, `Digit7`, `Digit8`, `Digit9`, `Digit0`.

### Other lists

- Ways of getting around (`player.modes`, `player.mode`): `walk`, `drive`, `fly`, `boat`, `bike`.
- Team colors: `red`, `blue`, `green`, `yellow`, `purple`, `orange`.
- Kinds of place (`eg.world.placesNear`): `depot`, `fuel`, `shop`, `office`, `hospital`, `police`, `street`. The last three come only when you ask for them.
- Weather presets (`eg.world.setWeather`): `clear`, `cloudy`, `overcast`, `rain`, `storm`, `snow`, `fog`.
- Vehicle handling profiles (`eg.vehicles.setHandling`): `arcade`, `sport`, `real`.
- Tire compounds (`eg.vehicles.setTire`): `slick`, `allweather`, `gravel`.
- Window block types (`eg.ui.window`): `heading`, `text`, `divider`, `stats`, `bar`, `list`, `table`, `callout`, `badges`, `actions`.
- Form field types (`eg.ui.form`): `text`, `number`, `select`, `checkbox`, `slider`.
- `{dist:1234}` in HUD text: a distance in meters, shown in the player's own units.
- `{km:2.5}` in HUD text: a trip length.
- `{time:95}` in HUD text: seconds as a clock: 1:35.

## Limits

Limits are budgets, not bans: they keep one game from hurting the others. If a good game needs more, ask the team.

### Your script

The rules script reacts to events; it does not run all the time. These keep one game from slowing the others.

| What | How much |
|---|---|
| Size of `server.js` | 256 KB |
| Size of `game.json` | 16 KB |
| Memory for one running game | 32 MB |
| Time to load the script | 250 ms |
| Time for one handler call | 8 ms. 3 time-outs in a row stop the script and end the game with a notice. |
| Platform calls in one handler call | 2000 |
| One value passed in or out (a save, a menu, a HUD card) | 64 KB |
| Events waiting for the script | 500. More than that are dropped; the dev panel says how many. |
| A timer that repeats | at most ten times a second |

### Things in the world

Per running game.

| What | How much |
|---|---|
| Zones and markers | 500 |
| Characters alive at once | 400 |
| Kinds of character | 64 |
| Spawners | 64 |
| Teams | 8 |
| Race courses of your own | 20 |
| Places from one `world.placesNear` | 64 |

### What players are sent

Toasts, HUD cards, windows, prompts, menus, effects and sounds, per player.

| What | How much |
|---|---|
| Messages | 15 a second, with bursts of up to 40 |
| Size of one message | 16 KB |
| A line of text (a toast, a label) | 200 characters |
| Open windows per player | 3 |
| Blocks per window | 30 |
| Fields / choices per prompt | 8 fields / 12 choices |
| Points in one `scores.add` | 100,000 |

### Players and running games

| What | How much |
|---|---|
| Players in one running game | 32 |
| Games one player may start | 12 an hour |
| An empty match closes after | 60 seconds |
| An empty persistent world is saved and closed after | 10 minutes |

### Translations

Text marked with `eg.t` and the `lang` folder (the guide: "Translating your game").

| What | How much |
|---|---|
| Texts to translate in one game | 2000 |
| One text, and one translation | 1000 characters |
| Languages in the `lang` folder | 80 |
| Size of the `lang` folder | 512 KB |
| Values in one `eg.t` | 20, each up to 200 characters |

### Saves

What `eg.saves` keeps.

| What | How much |
|---|---|
| A saved world | 200 keys, 256 KB in all |
| Kept for one player in your game | 50 keys, 16 KB in all |
| One value | 64 KB |
| Saved worlds one player may own | 10, and 3 of one game (a guest: 1) |
| A world nobody opens is removed after | 90 days (a guest's: 7 days) |

### Combat and inventories

| What | How much |
|---|---|
| Health a player may have | up to 10,000 (100 unless you say) |
| Different items one player carries | 40 |
| Of one item | 9,999 |

### Making and publishing

| What | How much |
|---|---|
| Drafts on one account | 10 |
| Published games on one account | 20 |
| Versions waiting for review | one per game: a newer submission replaces it |
| Games made in the Make a game app | 10, each with up to 60 placed things and 12 rule cards |
