Engine Class
Pages
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
คุณสมบัติ
วิธีการ
ได้รับทอดโดย
ตัวอย่างโค้ด
ตัววนรอบหน้า
-- ปรับรูปแบบหน้าเป็นตาราง
local function pagesToTable(pages)
local items = {}
while true do
table.insert(items, pages:GetCurrentPage())
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
end
return items
end
local function iterPageItems(pages)
local contents = pagesToTable(pages)
-- ติดตามหมายเลขหน้าปัจจุบันเริ่มต้นที่ 1
local pageNum = 1
-- รับหมายเลขหน้าสุดท้ายเพื่อไม่ให้วนซ้ำ
local lastPageNum = #contents
-- สำหรับการดำเนินการนี้ coroutine จนกว่าจะไม่มีอะไรให้ผ่าน
return coroutine.wrap(function()
-- วนซ้ำจนหมายเลขหน้ามากกว่าหมายเลขหน้าสุดท้าย
while pageNum <= lastPageNum do
-- ผ่านรายการทั้งหมดของหน้าปัจจุบัน
for _, item in ipairs(contents[pageNum]) do
-- หยุดการวนซ้ำเพื่อให้ผู้พัฒนาจัดการรายการและหมายเลขหน้า
coroutine.yield(item, pageNum)
end
pageNum += 1
end
end)
end
-- ใช้ฟังก์ชัน iterPageItems เพื่อวนรอบผ่านหน้าของการค้นหาคลังสินค้า
local AvatarEditorService = game:GetService("AvatarEditorService")
local parameters = CatalogSearchParams.new()
parameters.SearchKeyword = "Hair"
local catalogPages = AvatarEditorService:SearchCatalogAsync(parameters)
for item, pageNumber in iterPageItems(catalogPages) do
print(item, pageNumber)
endเอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
วิธีการ
AdvanceToNextPageAsync
Pages:AdvanceToNextPageAsync():()
ส่งค่ากลับ
()