學習
引擎類別
RecommendationPages
無法建立
未複製

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡


概要
繼承成員
範例程式碼
生成建議項目的列表
local RecommendationService = game:GetService("RecommendationService")
-- 定義生成建議列表的請求
local request: GenerateRecommendationItemListRequest = {
ConfigName = "MaximizeEngagement",
LocationId = "Lobby",
PageSize = 10
-- 注意:取消註解並為伺服器腳本設置 CustomContexts.UserId。
-- 對於本地腳本無需設置。
-- CustomContexts = {
-- ["UserId"] = tostring(player.UserId),
-- }
}
-- 呼叫 GenerateItemListAsync 以獲取建議頁面
local success, recommendationPages = pcall(function()
return RecommendationService:GenerateItemListAsync(request)
end)
if success then
-- 獲取當前頁面的建議項目
local currentPage = recommendationPages:GetCurrentPage()
for _, item in ipairs(currentPage) do
print("項目 ID: " .. item.ItemId)
print(" 參考 ID: " .. item.ReferenceId)
print(" 跟踪 ID: " .. item.TracingId)
end
else
warn("RecommendationService 錯誤: " .. tostring(recommendationPages))
end
--[[ 每個項目在頁面中的返回數據格式
{
"ItemId": string,
"ReferenceId": string,
"TracingId": string,
"Creator": {
"CreatorId": number,
"CreatorType": Enum.CreatorType,
}?,
"Attributes": {
{
"AssetId": number?,
"Text": string?,
"Description": string?,
"SeekStartTime": number?,
"SeekEndTime": number?,
"TrimStartTime": number?,
"TrimEndTime": number?
}
}?,
"CustomTags": { string }?
}
--]]
©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。