OrderedDataStore

Visualizza obsoleti

*Questo contenuto è tradotto usando AI (Beta) e potrebbe contenere errori. Per visualizzare questa pagina in inglese, clicca qui.

Non costruibile
Non Replicato

Un OrdinatedDataStore è essenzialmente un GlobalDataStore con l'eccezione che i valori memorizzati devono essere interi positivi .Esso espone un metodo GetSortedAsync() che consente l'ispezione delle voci in ordine ordinato utilizzando un oggetto DataStorePages.

Gli store di dati ordinati non supportano la versioning e i metadati, quindi DataStoreKeyInfo è sempre nil per le chiavi in un OrderedDataStore .Se hai bisogno di Assistenzaper la versionazione e i metadati, usa un DataStore .

I negozi di dati ordinati non supportano il parametro opzionale userIds per SetAsync() o IncrementAsync().

Vedi Magazzini di dati per una panoramica sull'utilizzo dei magazzini di dati ordinati.

Campioni di codice

This code sample demonstrates usage of an OrderedDataStore and pages.

OrderedDataStore Basics

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()
-- The data in 'topTen' is stored with the index being the index on the page
-- For each item, 'data.key' is the key in the OrderedDataStore and 'data.value' is the value
for rank, data in ipairs(topTen) do
local name = data.key
local points = data.value
print(name .. " is ranked #" .. rank .. " with " .. points .. "points")
end
-- Potentially load the next page...
--pages:AdvanceToNextPageAsync()
end
-- Create some data
pointsStore:SetAsync("Alex", 55)
pointsStore:SetAsync("Charley", 32)
pointsStore:SetAsync("Sydney", 68)
-- Display the top ten players
printTopTenPlayers()

Sommario

Metodi

Metodi provenienti da GlobalDataStore

Metodi

Proprietà

Metodi

GetSortedAsync

Resa

Parametri

ascending: boolean
Valore predefinito: ""
pagesize: number
Valore predefinito: ""
minValue: Variant
Valore predefinito: ""
maxValue: Variant
Valore predefinito: ""

Restituzioni

Eventi