DataStorePages
Mostrar obsoleto
*Este contenido se traduce usando la IA (Beta) y puede contener errores. Para ver esta página en inglés, haz clic en aquí.
Un tipo especial de objeto Pages que sus páginas contienen pares clave/valor de un OrderedDataStore .Para este objeto, GetCurrentPage() devuelve un array de tablas, cada una de las cuales contiene claves llamadas clave y valor ; estas reflejan los datos de la pareja clave/valor.
Muestras 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()
Resumen
Métodos
Métodos heredados de PagesDevuelve los elementos en la página actual. Las claves en el elemento se determinan por la fuente de este objeto.
Itera a la siguiente página en el objeto páginas, si es posible.
Propiedades
Propiedades heredado de Pages
Métodos
Propiedades heredado de Pages