Achievements
Last updated
bridge.achievements.unlock('level_10')
.then(() => {
// success
})
.catch(error => {
// error
})Bridge.achievements.Unlock("level_10", success =>
{
Debug.Log($"Achievement unlocked: {success}");
});{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-clicked","objectClass":"Button"}],"actions":[{"id":"achievements-unlock","objectClass":"PlaygamaBridge","parameters":{"id":"\"level_10\""}}]},{"eventType":"block","conditions":[{"id":"on-achievements-unlock-completed","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"is-last-action-completed-successfully","objectClass":"PlaygamaBridge"}],"actions":[{"type":"comment","text":"success"}]}]}]}{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button",""]}],"actions":[{"type":{"value":"PlaygamaBridge::AchievementsUnlock"},"parameters":["","\"level_10\"",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnAchievementsUnlockCompleted"},"parameters":["",""]}],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::IsLastActionCompletedSuccessfully"},"parameters":["",""]}],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["\"success\"","\"info\"",""]}]}],"actions":[]}],"eventsCount":2,"actionsList":[],"actionsCount":0,"conditionsList":[],"conditionsCount":0}}Bridge.achievements.unlock("level_10", funcref(self, "_on_unlock_completed"))
func _on_unlock_completed(success):
print(success)Bridge.achievements.unlock("level_10", Callable(self, "_on_unlock_completed"))
func _on_unlock_completed(success):
print(success)playgama_bridge_achievements_unlock("level_10")
// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_achievements_unlock_callback" {
if async_load[? "success"] {
// your logic
}
}local bridge = require("bridge.bridge")
function init(self)
bridge.achievements.unlock(
"level_10",
function ()
-- success
end,
function ()
-- error
end
)
endbridge.achievements.unlock('level_10')
.then(() => {
// success
})
.catch(error => {
// error
})[
{
id: 'level_10', // game-level id from the config
name: 'Level 10', // optional
description: '...', // optional
unlocked: true
}
]bridge.achievements.getAchievements()
.then(achievements => {
achievements.forEach(achievement => {
console.log(achievement.id, achievement.unlocked)
})
})
.catch(error => {
// error
})private void Start()
{
Bridge.achievements.GetAchievements(OnGetAchievementsCompleted);
}
private void OnGetAchievementsCompleted(bool success, List<Dictionary<string, string>> achievements)
{
if (success)
{
foreach (var achievement in achievements)
{
Debug.Log($"{achievement["id"]}: {achievement["unlocked"]}");
}
}
}{"is-c3-clipboard-data":true,"type":"events","items":[{"eventType":"block","conditions":[{"id":"on-clicked","objectClass":"Button"}],"actions":[{"id":"achievements-get-list","objectClass":"PlaygamaBridge"}]},{"eventType":"block","conditions":[{"id":"on-achievements-get-list-completed","objectClass":"PlaygamaBridge"}],"actions":[],"children":[{"eventType":"block","conditions":[{"id":"for","objectClass":"System","parameters":{"name":"\"achievements\"","start-index":"0","end-index":"PlaygamaBridge.AchievementsCount - 1"}}],"actions":[{"id":"log","objectClass":"Browser","parameters":{"type":"log","message":"PlaygamaBridge.AchievementPropertyValue(loopindex(\"achievements\"), \"id\") & \": \" & PlaygamaBridge.AchievementPropertyValue(loopindex(\"achievements\"), \"unlocked\")"}}]}]}]}{"000kind":"GDEVELOP_EventsAndInstructions_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsList":[{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PanelSpriteButton::PanelSpriteButton::IsClicked"},"parameters":["Button",""]}],"actions":[{"type":{"value":"PlaygamaBridge::AchievementsGetList"},"parameters":["",""]}]},{"type":"BuiltinCommonInstructions::Standard","conditions":[{"type":{"value":"PlaygamaBridge::OnAchievementsGetListCompleted"},"parameters":["",""]}],"actions":[{"type":{"value":"SetNumberVariable"},"parameters":["CurrentIndex","=","0"]}],"events":[{"type":"BuiltinCommonInstructions::Repeat","repeatExpression":"PlaygamaBridge::AchievementsCount()","conditions":[],"actions":[],"events":[{"type":"BuiltinCommonInstructions::Standard","conditions":[],"actions":[{"type":{"value":"DebuggerTools::ConsoleLog"},"parameters":["PlaygamaBridge::AchievementPropertyValue(CurrentIndex, \"id\") + \": \" + PlaygamaBridge::AchievementPropertyValue(CurrentIndex, \"unlocked\")","\"info\"",""]},{"type":{"value":"SetNumberVariable"},"parameters":["CurrentIndex","+","1"]}]}]}]}],"eventsCount":2,"actionsList":[],"actionsCount":0,"conditionsList":[],"conditionsCount":0}}Bridge.achievements.get_achievements(funcref(self, "_on_get_achievements_completed"))
func _on_get_achievements_completed(success, achievements):
if success:
for achievement in achievements:
print(achievement.id, ": ", achievement.unlocked)Bridge.achievements.get_achievements(Callable(self, "_on_get_achievements_completed"))
func _on_get_achievements_completed(success, achievements):
if success:
for achievement in achievements:
print(achievement.id, ": ", achievement.unlocked)playgama_bridge_achievements_get_achievements()
// callback via Async Social Event
if async_load[? "type"] == "playgama_bridge_achievements_get_achievements_callback" {
if async_load[? "success"] {
var achievements = json_parse(async_load[? "data"])
for (var i = 0; i < array_length(achievements); i += 1) {
var achievement = achievements[i]
// achievement.id, achievement.unlocked
}
}
}local bridge = require("bridge.bridge")
function init(self)
bridge.achievements.get_achievements(
function (_, achievements_json)
local achievements = json.decode(achievements_json)
for _, achievement in ipairs(achievements) do
print(achievement.id, achievement.unlocked)
end
end,
function ()
-- error
end
)
endbridge.achievements.getAchievements()
.then(achievements => {
achievements.forEach(achievement => {
console.log(achievement.id, achievement.unlocked)
})
})
.catch(error => {
// error
})