エンジンクラス
OrderedDataStore
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
方法
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)
-- 上位10人のプレイヤーを表示します
printTopTenPlayers()APIリファレンス
方法
GetSortedAsync
OrderedDataStore:GetSortedAsync(