DataStorePages
Mostrar obsoleto
*Este conteúdo é traduzido por IA (Beta) e pode conter erros. Para ver a página em inglês, clique aqui.
Um tipo especial de objeto Pages que suas páginas contêm pares de chave/valor de um OrderedDataStore .Para este Objeto, GetCurrentPage() retorna um array de tabelas, cada uma contendo chaves chamadas chave e valor ; estes refletem os dados de par de chave/valor.
Amostras de código
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()
Resumo
Métodos
Métodos herdados de PagesRetorna os itens na página atual. As chaves no item são determinadas pela fonte deste Objeto.
Itera para a próxima página no objeto Páginas, se possível.
Propriedades
Propriedades herdado de Pages
Métodos
Propriedades herdado de Pages