# aego/update

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

A game updates itself when `project.aego` names its update server and the key that signs its releases:

```
update {
  url="https://example.com/mygame/updates"
  publicKey="<the public key from aego release keygen>"
}
```

The server holds one folder per channel, `stable/release.json` and `nightly/release.json`, each with its `release.json.sig`. `aego export --release-json` writes both next to the exported archive. The game checks at start; in the Auto mode it downloads the new version in the background, and the Settings View gets **Updates** and **Update channel**. Nothing installs without a valid signature and checksum. The sandbox has no update server, so this example needs a project.

## Example

```aes check
package demo

import (
    "aego/log"
    "aego/update"
)

script UpdateBanner {
    var shown bool

    func Update(dt float) {
        if !shown && update.State() == "ready" {
            shown = true
            log.Info("version " + update.Version() + " is ready: " + update.Notes())
        }
    }

    func Restart() {
        if update.State() == "ready" {
            update.Apply()
        }
    }
}
```

## Apply

```
func Apply()
```

Installs the downloaded version and restarts the game on it; save the player's progress first.

## Check

```
func Check()
```

Looks for a newer version on the game's update server in the background; State says what it found.

## Download

```
func Download()
```

Fetches the newer version in the background; Auto mode does it on its own.

## Error

```
func Error() string
```

Says why the last check or download failed.

## Notes

```
func Notes() string
```

Notes are the release notes of the newer version.

## State

```
func State() string
```

Is idle, checking, upToDate, available, downloading, ready or failed.

## Version

```
func Version() string
```

Is the newer version the last check found, empty when there is none.
