Справочник функций
Godot 4 · GDScript · Cloud saves
save_game
Writes (upserts) a cloud save slot with a free-form data object.
Asynchronous (result via signal)
Signature
save_game(slot: int, data: Dictionary) -> voidWhat it does
POSTs /saves (upsert on game+player+slot), so it is safe to retry. On success meta = { slot, size_bytes, updated_at }; {} on failure. error_code is "" on success, else one of no_session / invalid_slot / not_configured / plan / too_large / storage_full / slot_limit / validation / rate_limited / internal.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| slot | int | required | Save slot, 1-10. |
| data | Dictionary | required | Your save object; must be a JSON object matching the save schema you define in the panel. The submit route accepts up to 10MB. |
How to call it
Connect save_completed first, then call save_game().
Result signal: save_completed(success: bool, slot: int, meta: Dictionary, error_code: String)
Example
Gamdato.save_completed.connect(_on_saved)
Gamdato.save_game(1, {"level": 5, "coins": 120, "unlocked": ["sword"]})
func _on_saved(ok: bool, slot: int, meta: Dictionary, error_code: String) -> void:
if ok: print("Saved slot %d (%d bytes)" % [slot, meta.size_bytes])
else: print("Save failed: %s" % error_code)Use cases
- Persist player progress to the cloud.
- Sync a player's game across devices.