SortedCloudStore¶
Type
SortedCloudStore is a shared leaderboard of whole-number scores opened with CloudStore.OpenSorted; see CloudStore for request budgets. Keys are strings of 1 to 128 printable characters, and scores are whole numbers strictly within (-2^53, 2^53).
Every method yields until the request finishes and returns a StoreStatus first. A local test server keeps scores in memory, so they are gone when it stops.
Set¶
Set saves a whole-number score under key and returns a StoreStatus.
Example
Get¶
Get loads the score saved under key and returns (status, score). A missing key returns "Ok", nil.
Example
GetSorted¶
GetSorted loads up to Limit (1 to 100, default 100) { Key, Score } entries sorted by score (Order = "Descending" by default, or "Ascending") and returns (status, entries). Optional Min, Max, and After fields bound the score range or continue after the last entry of the previous page.
Example
-- Server script.
local wins = CloudStore.OpenSorted("total_wins")
task.spawn(function()
local status, entries = wins:GetSorted({ Order = "Descending", Limit = 10 })
if status ~= "Ok" or not entries then
warn(status)
return
end
for rank, entry in entries do
print(rank, entry.Key, entry.Score)
end
end)
Remove¶
Remove deletes key from the sorted store and returns (status, removed).
Example
Increment¶
Increment adds whole-number delta to key atomically (starting from 0 if absent) and returns (status, score). If the new score would reach 2^53 in magnitude, Increment returns "TooLarge", nil.