DataStorePages

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

无法创建
未复制

一个特殊类型的 Pages 对象,其页面包含来自 OrderedDataStore 的键/值对组。对于这个对象,GetCurrentPage()返回一个阵列表,每个包含名为 keyvalue 的键和值;这些反映了键/值对数据。

代码示例

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()

概要

属性

继承自Pages属性
  • 只读
    未复制
    读取并联

    当前页是否为可用的最后一页。

方法

继承自Pages方法

属性

方法

活动