Ordered Data Store
概要
方法
GetSortedAsync(ascending: boolean,pagesize: number,minValue: Variant,maxValue: Variant):DataStorePages |
コードサンプル
OrderedDataStoreの基本
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リファレンス
方法
Get Sorted Async
Ordered Data Store: Get Sorted Async(