# aego/settings

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

`Get*` return the effective value. `Set*` only stage a value; `Apply` makes every staged value take effect at once and `Revert` drops them. `Override*` change a value for this session only and are never saved. Scripts with `OnSettingChanged(id string)` hear about every change. The documentation sandbox does not load the Settings module, so this example needs a project. See [Settings](/settings.md).

## Example

```aes check
package demo

import (
    "aego/log"
    "aego/settings"
)

script Shaker {
    @export var Strength float = 1

    var frames int

    func Ready() {
        log.Info("screen shake " + string(settings.GetFloat("accessibility.screenShake")) + ", reduced motion " + string(settings.GetBool("accessibility.reducedMotion")))
        settings.OverrideFloat("accessibility.screenShake", 0.25)
    }

    func Update(dt float) {
        frames++
        if frames == 30 {
            shake := Strength * settings.GetFloat("accessibility.screenShake")
            log.Info("shaking with " + string(shake))
            settings.ClearOverride("accessibility.screenShake")
        }
    }

    func OnSettingChanged(id string) {
        log.Info(id + " is now " + string(settings.GetFloat(id)))
    }
}
```

## Apply

```
func Apply() bool
```

Applies every staged value at once; if one fails, none change.

## ClearOverride

```
func ClearOverride(id string)
```

Removes a session override.

## ClearOverrides

```
func ClearOverrides()
```

Removes every session override.

## CloseView

```
func CloseView()
```

Hides the settings screen.

## GetBool

```
func GetBool(id string) bool
```

Returns the effective value of an on/off setting.

## GetFloat

```
func GetFloat(id string) float
```

Returns the effective value of a number setting.

## GetInt

```
func GetInt(id string) int
```

Returns the effective value of an integer or choice setting.

## GetString

```
func GetString(id string) string
```

Returns a text setting, or the name of the current choice.

## NeedsRestart

```
func NeedsRestart() bool
```

Reports whether an applied setting takes effect only after a restart.

## OpenView

```
func OpenView()
```

Shows the settings screen and pauses the game until it closes.

## OverrideBool

```
func OverrideBool(id string, value bool)
```

Sets an on/off value for this session only.

## OverrideFloat

```
func OverrideFloat(id string, value float)
```

Sets a value for this session only; it is never saved.

## OverrideInt

```
func OverrideInt(id string, value int)
```

Sets an integer for this session only.

## OverrideString

```
func OverrideString(id string, value string)
```

Sets a text value for this session only.

## Reset

```
func Reset(id string)
```

Stages a return to the project default.

## Revert

```
func Revert()
```

Drops the staged values.

## Save

```
func Save()
```

Writes the player profile now; it is also saved on its own shortly after a change.

## SetBool

```
func SetBool(id string, value bool)
```

Stages a value; Apply makes it take effect.

## SetFloat

```
func SetFloat(id string, value float)
```

Stages a number.

## SetInt

```
func SetInt(id string, value int)
```

Stages an integer or choice index.

## SetString

```
func SetString(id string, value string)
```

Stages a text value.

## ViewOpen

```
func ViewOpen() bool
```

Reports whether the settings screen is shown.
