学习
引擎类
OrderedDataStore
无法创建
未复制

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处


概要
方法
GetSortedAsync(ascending: boolean,pagesize: number,minValue: Variant,maxValue: Variant):DataStorePages
继承成员
代码示例
排序数据存储基础
local DataStoreService = game:GetService("DataStoreService")
local pointsStore = DataStoreService:GetOrderedDataStore("Points")
local function printTopTenPlayers()
local isAscending = false
local pageSize = 10
local pages = pointsStore:GetSortedAsync(isAscending, pageSize)
local topTen = pages:GetCurrentPage()
-- 'topTen' 中的数据是以页上的索引为索引存储的
-- 对于每个项,'data.key' 是在 OrderedDataStore 中的键,而 'data.value' 是值
for rank, data in ipairs(topTen) do
local name = data.key
local points = data.value
print(name .. " 的排名是 #" .. rank .. ",得分 " .. points .. "分")
end
-- 可能加载下一页...
--pages:AdvanceToNextPageAsync()
end
-- 创建一些数据
pointsStore:SetAsync("Alex", 55)
pointsStore:SetAsync("Charley", 32)
pointsStore:SetAsync("Sydney", 68)
-- 显示前十名玩家
printTopTenPlayers()

API 参考
方法
GetSortedAsync
暂停
功能: DataStore
OrderedDataStore:GetSortedAsync(
ascending:boolean, pagesize:number, minValue:Variant, maxValue:Variant
参数
ascending:boolean
pagesize:number
minValue:Variant
maxValue:Variant

©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。