Functions Reference
Godot 4 · GDScript · Achievements
unlock_achievement
Unlocks an achievement for the current player (idempotent).
Asynchronous (result via signal)
Signature
unlock_achievement(achievement_key: String) -> voidWhat it does
POSTs /achievements/unlock (session-auth). Idempotent server-side: unlocking twice reports already_unlocked=true instead of failing (still success=true). Unknown or inactive keys fail (success=false), as does calling with no active session or an empty key.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| achievement_key | String | required | The achievement's key from the panel. |
How to call it
Connect achievement_unlocked first, then call unlock_achievement().
Result signal: achievement_unlocked(success: bool, achievement_key: String, already_unlocked: bool)
Example
Gamdato.achievement_unlocked.connect(_on_unlocked)
Gamdato.unlock_achievement("first_win")
func _on_unlocked(ok: bool, key: String, already: bool) -> void:
if ok and not already:
print("unlocked %s" % key)Use cases
- Grant an achievement when the player hits a milestone.
- Safely re-call on load without double-granting (already_unlocked guards it).