aego/update
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
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()
}
}
}
Functions
| Apply | () | Installs the downloaded version and restarts the game on it; save the player's progress first. |
| Check | () | Looks for a newer version on the game's update server in the background; State says what it found. |
| Download | () | Fetches the newer version in the background; Auto mode does it on its own. |
| Error | () string | Says why the last check or download failed. |
| Notes | () string | Notes are the release notes of the newer version. |
| State | () string | Is idle, checking, upToDate, available, downloading, ready or failed. |
| Version | () string | Is the newer version the last check found, empty when there is none. |
Apply function
func Apply()
Installs the downloaded version and restarts the game on it; save the player's progress first.
Example
if update.State() == "ready" { update.Apply() }
Check function
func Check()
Looks for a newer version on the game's update server in the background; State says what it found.
Example
update.Check()
Download function
func Download()
Fetches the newer version in the background; Auto mode does it on its own.
Example
update.Download()
Error function
func Error() string
Says why the last check or download failed.
Example
log.Warn(update.Error())
Notes function
func Notes() string
Notes are the release notes of the newer version.
Example
notes.Text = update.Notes()
State function
func State() string
Is idle, checking, upToDate, available, downloading, ready or failed.
Example
if update.State() == "ready" {
Version function
func Version() string
Is the newer version the last check found, empty when there is none.
Example
label.Text = "Version " + update.Version() + " is ready"