# Achievements

**Support**

Use this to determine if you can implement achievements for your game on the current platform.

```gdscript
Bridge.achievements.is_supported
```

Check if getting list of achievements is supported.

```
Bridge.achievements.is_get_list_supported
```

Check if built-in popup is supported.

```
Bridge.achievements.is_native_popup_supported
```

#### Unlock achievement <a href="#purchase" id="purchase"></a>

Unlocks achievement for a player.

{% tabs %}
{% tab title="Godot 3.x" %}

<pre class="language-gdscript"><code class="lang-gdscript"><strong>func _ready():
</strong><strong>    var options
</strong>
    match Bridge.platform.id:
        "y8":
            options = {
                "achievementkey": "YOUR_ACHIEVEMENT_KEY",
                "achievement": "YOUR_ACHIEVEMENT_NAME"
            }
        "lagged":
            options = {
                "achievement": "YOUR_LEADERBOARD_ID",
            }

    Bridge.achievements.unlock(options, funcref(self, "_on_unlock_completed"))

func _on_unlock_completed(success):
    print(success)
</code></pre>

{% endtab %}

{% tab title="Godot 4.x" %}

<pre class="language-gdscript"><code class="lang-gdscript"><strong>func _ready():
</strong><strong>    var options
</strong>
    match Bridge.platform.id:
        "y8":
            options = {
                "achievementkey": "YOUR_ACHIEVEMENT_KEY",
                "achievement": "YOUR_ACHIEVEMENT_NAME"
            }
        "lagged":
            options = {
                "achievement": "YOUR_LEADERBOARD_ID",
            }

    Bridge.achievements.unlock(options, Callable(self, "_on_unlock_completed"))

func _on_unlock_completed(success):
    print(success)
</code></pre>

{% endtab %}
{% endtabs %}

**Get List**

Returns the achievement list in JSON

{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
func _on_get_list_button_pressed():
    var options
    
    Bridge.achievements.get_list(options, funcref(self, "_on_get_list_completed"))

func _on_get_list_completed(success, list):
    print(success)
    
    match Bridge.platform.id:
        "y8":
            for item in list:
                print("achievementid:" + str(item.achievementid))
                print("achievement:" + str(item.achievement))
                print("achievementkey:" + str(item.achievementkey))
                print("description:" + str(item.description))
                print("icon:" + str(item.icon))
                print("difficulty:" + str(item.difficulty))
                print("secret:" + str(item.secret))
                print("awarded:" + str(item.awarded))
                print("game:" + str(item.game))
                print("link:" + str(item.link))
                print("playerid:" + str(item.playerid))
                print("playername:" + str(item.playername))
                print("lastupdated:" + str(item.lastupdated))
                print("date:" + str(item.date))
                print("rdate:" + str(item.rdate))
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
func _on_get_list_button_pressed():
    var options
    
    Bridge.achievements.get_list(options, Callable(self, "_on_get_list_completed"))

func _on_get_list_completed(success, list):
    print(success)
    
    match Bridge.platform.id:
        "y8":
            for item in list:
                print("achievementid:" + str(item.achievementid))
                print("achievement:" + str(item.achievement))
                print("achievementkey:" + str(item.achievementkey))
                print("description:" + str(item.description))
                print("icon:" + str(item.icon))
                print("difficulty:" + str(item.difficulty))
                print("secret:" + str(item.secret))
                print("awarded:" + str(item.awarded))
                print("game:" + str(item.game))
                print("link:" + str(item.link))
                print("playerid:" + str(item.playerid))
                print("playername:" + str(item.playername))
                print("lastupdated:" + str(item.lastupdated))
                print("date:" + str(item.date))
                print("rdate:" + str(item.rdate))
```

{% endtab %}
{% endtabs %}

**Show Native Popup**

Some platforms support built-in achievement list which is shown in overlay

{% tabs %}
{% tab title="Godot 3.x" %}

```gdscript
func _on_show_native_popup_button_pressed():
    var options
    
    Bridge.achievements.show_native_popup(options, funcref(self, "_on_show_native_popup_completed"))

func _on_show_native_popup_completed(success):
    print(success)
```

{% endtab %}

{% tab title="Godot 4.x" %}

```gdscript
func _on_show_native_popup_button_pressed():
    var options
    
    Bridge.achievements.show_native_popup(options, Callable(self, "_on_show_native_popup_completed"))

func _on_show_native_popup_completed(success):
    print(success)
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.playgama.com/playgama/sdk/engines/godot/achievements.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
