Files
sanspie f22242e5aa
ci / release (push) Successful in 5m5s
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci / checks (push) Successful in 4m41s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 7m14s
Stage 11g2–11g3: registry texts, CLI and the site in Russian (D348)
The remaining editor strings and undo step names; component, field, enum, setting, diagnostic and Script API texts under schema.*, enum.*, setting.*, diag.* and api.*; the launcher, the in-game Settings View with a Language setting, the CLI and aego schema show --lang. Every documentation page has a .ru.md translation; the site has a full Russian tree with hreflang, a language switch and ru/llms.txt; aego docs check --lang ru. New doc.tutorial and doc.recipe icons. Fix: an animator restored by a rewind prepares its controller before the replayed step.
2026-10-25 15:31:22 +03:00

52 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
id: aego/save
summary: Сохраняет и загружает игры в именованных слотах, хранит значения узлов в OnSave и OnLoad и ведёт прогресс всей игры.
---
`Save` и `Load` срабатывают в конце кадра. `Put*` вызывают в `OnSave`, а `Get*` — в `OnLoad`; их ключи принадлежат узлу. Значения `SetGlobal*` переносит каждое сохранение. В песочнице документации нет сохранений, поэтому этому примеру нужен проект. См. [Сохранение игр](ref:save).
## Пример
```aes check
package demo
import (
"aego/log"
"aego/save"
)
script Checkpoints {
var reached int
var frames int
func Ready() {
log.Info("runs so far " + string(save.GlobalInt("runs", 0)) + ", slot1 exists: " + string(save.Exists("slot1")))
save.SetGlobalInt("runs", save.GlobalInt("runs", 0) + 1)
}
func Update(dt float) {
frames++
if frames == 30 {
reached = 2
node.SetPosition(Vec2{5, 0})
save.Save("slot1")
log.Info("saved at checkpoint " + string(reached))
}
if frames == 31 {
log.Info("slot1 exists: " + string(save.Exists("slot1")))
}
}
func OnSave() {
save.PutInt("reached", reached)
save.PutVec2("respawn", node.Position())
}
func OnLoad() {
reached = save.GetInt("reached", 0)
node.SetPosition(save.GetVec2("respawn", Vec2{}))
log.Info("loaded checkpoint " + string(reached))
}
}
```