OrderedDataStore

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่

ไม่สามารถสร้าง
ไม่ซ้ำ

A ร้านข้อมูลสั่งซื้อ เป็นหลักเป็นเพียง GlobalDataStore ยกเว้นว่ามูลค่าที่เก็บไว้จะต้องเป็นตัวเลขบวก **** มันเปิดเผยวิธี GetSortedAsync() ซึ่งสามารถตรวจสอบเอนทรีในลำดับที่เรียงลําดับโดยใช้วัตถุ DataStorePages

ร้านข้อมูลที่สั่งซื้อไม่สนับสนุนการจัดเวอร์ชันและเมทาดาต้า ดังนั้น DataStoreKeyInfo จึงเป็นเสมอ nil สำหรับกุญแจใน OrderedDataStoreหากต้องการการสนับสนุนเวอร์ชันและข้อมูลคำอธิบาย, ให้ใช้ DataStore

ร้านข้อมูลที่สั่งซื้อไม่สนับสนุนพารามิเตอร์ทางเลือก userIds สำหรับ SetAsync() หรือ IncrementAsync()

ดู ร้านข้อมูล สำหรับภาพรวมเกี่ยวกับการใช้ร้านข้อมูลที่สั่งซื้อ

ตัวอย่างโค้ด

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

สรุป

วิธีการ

วิธีการรับทอดมาจากGlobalDataStore
  • ผลตอบแทน

    ส่งค่าของกุญแจในคลังข้อมูลที่กำหนดและตัวอย่าง DataStoreKeyInfo อินสแตนซ์

  • IncrementAsync(key : string,delta : number,userIds : Array,options : DataStoreIncrementOptions):Variant
    ผลตอบแทน

    เพิ่มมูลค่าของกุญแจโดยจำนวนที่กำหนด (ทั้งสองต้องเป็นตัวเลข)

  • ผลตอบแทน

    ลบคีย์ที่ระบุโดยยังคงรักษารุ่นที่เข้าถึงได้

  • SetAsync(key : string,value : Variant,userIds : Array,options : DataStoreSetOptions):Variant
    ผลตอบแทน

    ตั้งค่าค่าของคลังข้อมูลสำหรับกุญแจที่กำหนดไว้

  • UpdateAsync(key : string,transformFunction : function):Tuple
    ผลตอบแทน

    อัปเดตค่าของกุญแจด้วยค่าใหม่จากฟังก์ชันการโทรกลับที่กำหนดไว้

คุณสมบัติ

วิธีการ

GetSortedAsync

ผลตอบแทน

ส่งคืนวัตถุ DataStorePagesลำดับการจัดเรียงจะถูกกำหนดโดย เพิ่มขึ้น , ความยาวของแต่ละหน้าโดย pageSize และ minValue / maxValue เป็นพารามิเตอร์ที่เลือกได้ซึ่งจะกรองผลลัพธ์

ดู ร้านข้อมูล สำหรับขีดจํากัดคำขอและคําอธิบายของรหัสข้อผิดพลาด

พารามิเตอร์

ascending: boolean

เป็นไบนารีที่ระบุว่าหน้าข้อมูลที่ส่งคืนอยู่ในลำดับเพิ่มขึ้นหรือไม่

ค่าเริ่มต้น: ""
pagesize: number

ความยาวของแต่ละหน้า โดยค่าเริ่มต้นคือ 50 ค่าสูงสุดที่อนุญาตคือ 100

ค่าเริ่มต้น: ""
minValue: Variant

พารามิเตอร์ทางเลือก หากตั้งค่าแล้ว หน้าข้อมูลที่มีค่าน้อยกว่า minValue จะถูกยกเลิก

ค่าเริ่มต้น: ""
maxValue: Variant

พารามิเตอร์ทางเลือก หากตั้งค่าแล้ว หน้าข้อมูลที่มีค่ามากกว่า maxValue จะถูกยกเลิก

ค่าเริ่มต้น: ""

ส่งค่ากลับ

วัตถุจัดเรียง DataStorePages ที่อ้างอิงตามอาร์กิวเมนต์ที่ให้ไว้

อีเวนต์