Enhance competitiveness by integrating leaderboards, allowing players to compare their scores and achievements.
Support
Use this to determine if you can implement leaderboards for your game on the current platform.
Check if the leaderboard feature is supported on the platform.
bridge.leaderboard.is_supported()
Check if built-in popup is supported.
bridge.leaderboard.is_native_popup_supported()
Check if multiple boards are supported.
bridge.leaderboard.is_multiple_boards_supported()
Check if user can set score to leaderboard.
bridge.leaderboard.is_set_score_supported()
Check if user can retrieve their score.
bridge.leaderboard.is_get_score_supported()
Check if user can access leaderboard entries including other players' scores.
bridge.leaderboard.is_get_entries_supported()
Player Scores. Set
Submit the player's score to the leaderboard to update their rank and position.
local bridge = require("bridge.bridge")
function init(self)
local options = {
yandex = {
leaderboardName = "YOUR_LEADERBOARD_NAME",
score = 42
},
facebook = {
leaderboardName = "YOUR_LEADERBOARD_NAME",
score = 42
},
lagged = {
boardId = "YOUR_LEADERBOARD_ID",
score = 42
},
y8 = {
table = "YOUR_LEADERBOARD_NAME",
points = 42
}
}
bridge.leaderboard.set_score(options, function ()
-- success
end, function ()
-- error
end)
end
Player Scores. Get
Retrieve the player's score from the leaderboard to display their current standing.
local bridge = require("bridge.bridge")
function init(self)
local options = {
yandex = {
leaderboardName = "YOUR_LEADERBOARD_NAME"
},
facebook = {
leaderboardName = "YOUR_LEADERBOARD_NAME",
},
y8 = {
table = "YOUR_LEADERBOARD_NAME"
}
}
bridge.leaderboard.get_score(options, function (_, data)
print("Leaderboard score: ", data)
end, function ()
-- error
end)
end
Get Full Leaderboard
Retrieve entries from the leaderboard, including the player's rank and score, to display a comprehensive leaderboard.
local bridge = require("bridge.bridge")
function init(self)
local options = {
yandex = {
leaderboardName = "YOUR_LEADERBOARD_NAME",
includeUser = true, -- default = false
quantityAround = 10, -- default = 5
quantityTop = 10 -- default = 5
},
facebook = {
leaderboardName = "YOUR_LEADERBOARD_NAME",
count = 10, -- default = 5
offset = 10 -- default = 0
},
y8 = {
table = "YOUR_LEADERBOARD_NAME",
perPage = 5, -- optional, default = 20, max = 100
page = 1, -- optional, default = 1
mode = "alltime", -- optional, "alltime" | "last30days" | "last7days" | "today" | "newest"
},
}
bridge.leaderboard.get_entries(options, function (_, data)
-- success
end, function ()
-- error
end)
end
Shows leaderboard entries built-in popup
local bridge = require("bridge.bridge")
function init(self)
options = {
y8 = {
table = "YOUR_LEADERBOARD_NAME"
}
}
bridge.leaderboard.show_native_popup(options, function (_, data)
-- success
end, function ()
-- error
end)
end