Avatar Editor Service
概要
方法
活動
PromptCreateOutfitCompleted(result: Enum.AvatarPromptResult,failureType: Variant):RBXScriptSignal |
PromptSaveAvatarCompleted(result: Enum.AvatarPromptResult,humanoidDescription: HumanoidDescription):RBXScriptSignal |
API 參考
方法
Check Apply Default Clothing
Check Apply Default Clothing Async
Avatar Editor Service: Check Apply Default Clothing Async(humanoid Description:HumanoidDescription):HumanoidDescription
參數
Conform To Avatar Rules
Conform To Avatar Rules Async
Avatar Editor Service: Conform To Avatar Rules Async(humanoid Description:HumanoidDescription):HumanoidDescription
參數
Get Accessory Type
參數
Get Avatar Rules
Get Batch Item Details
Get Batch Item Details Async
參數
返回
Get Bundles By Asset Id Async
Get Favorite
Get Favorite Async
參數
返回
Get Head Shapes Async
返回
範例程式碼
獲取擁有的頭型
local AvatarEditorService = game:GetService("AvatarEditorService")
-- 提示允許讀取庫存訪問
AvatarEditorService:PromptAllowInventoryReadAccess()
local result = AvatarEditorService.PromptAllowInventoryReadAccessCompleted:Wait()
if result == Enum.AvatarPromptResult.Success then
-- 獲取頭部形狀
local shapes = AvatarEditorService:GetHeadShapesAsync()
for i, shape in ipairs(shapes) do
print(i, shape)
end
endGet Inventory
Get Inventory Async
參數
範例程式碼
尋找即將過期的物品
local AvatarEditorService = game:GetService("AvatarEditorService")
local pages = AvatarEditorService:GetInventoryAsync({ Enum.AvatarAssetType.Hat })
local currentPage = pages:GetCurrentPage()
for _, item in currentPage do
if item.ExpirationTime then
local secondsLeft = item.ExpirationTime.UnixTimestamp - DateTime.now().UnixTimestamp
local hoursLeft = math.floor(secondsLeft / 3600)
if hoursLeft < 24 then
warn(string.format("%s 在 %d 小時內過期", item.Name, hoursLeft))
end
end
endGet Item Details
Get Item Details Async
參數
範例程式碼
檢查物品過期
local AvatarEditorService = game:GetService("AvatarEditorService")
local details = AvatarEditorService:GetItemDetailsAsync(105589844216517, Enum.AvatarItemType.Asset)
if details.ExpirationTime then
local secondsLeft = details.ExpirationTime.UnixTimestamp - DateTime.now().UnixTimestamp
local hoursLeft = math.floor(secondsLeft / 3600)
if hoursLeft < 24 then
warn(details.Name .. " 在24小時內過期!")
end
endGet Outfit Details
Get Outfit Details Async
Get Outfits
Get Outfits Async
Avatar Editor Service: Get Outfits Async(
參數
| 預設值:All |
| 預設值:All |
Get Recommended Assets
Get Recommended Assets Async
Avatar Editor Service: Get Recommended Assets Async(
參數
| 預設值:0 |
返回
範例程式碼
獲取帽子推薦
local AvatarEditorService = game:GetService("AvatarEditorService")
local assets = AvatarEditorService:GetRecommendedAssetsAsync(Enum.AvatarAssetType.Hat, 9255093)
for _, asset in ipairs(assets) do
print(asset.Item.Name)
endGet Recommended Bundles
Get Recommended Bundles Async
Prompt Allow Inventory Read Access
Avatar Editor Service: Prompt Allow Inventory Read Access():()
返回
()
Prompt Create Outfit
Avatar Editor Service: Prompt Create Outfit(
outfit:HumanoidDescription, rig Type:Enum.HumanoidRigType, outfit Options:Dictionary, outfit Type:Variant
):()
參數
| 預設值:nil |
outfitType:Variant |
返回
()
Prompt Save Avatar
Avatar Editor Service: Prompt Save Avatar(
):()
參數
返回
()
Prompt Set Favorite
Avatar Editor Service: Prompt Set Favorite(
):()
參數
返回
()
Prompt Update Outfit
Avatar Editor Service: Prompt Update Outfit(
):()
參數
返回
()
Search Catalog
Search Catalog Async
參數
範例程式碼
搜索具有時間選項的物品
local AvatarEditorService = game:GetService("AvatarEditorService")
local params = CatalogSearchParams.new()
params.SalesTypeFilter = Enum.SalesTypeFilter.TimedOptions
params.Limit = 10
local pages = AvatarEditorService:SearchCatalogAsync(params)
local results = pages:GetCurrentPage()
for _, item in results do
if item.TimedOptions then
for _, option in item.TimedOptions do
local days = option.Duration / 86400
print(string.format("%s: %d 天的 %d R$", item.Name, days, option.Price))
end
end
end活動
Prompt Allow Inventory Read Access Completed
Avatar Editor Service. Prompt Allow Inventory Read Access Completed(result:Enum.AvatarPromptResult):RBXScriptSignal
參數
Prompt Create Outfit Completed
Avatar Editor Service. Prompt Create Outfit Completed(
參數
failureType:Variant |
範例程式碼
處理服裝創建結果
local AvatarEditorService = game:GetService("AvatarEditorService")
AvatarEditorService.PromptCreateOutfitCompleted:Connect(function(result, failureType)
if result == Enum.AvatarPromptResult.Success then
-- 服裝已創建
elseif result == Enum.AvatarPromptResult.PermissionDenied then
-- 用戶拒絕了提示;忽略 failureType
else -- Enum.AvatarPromptResult.Failed
if failureType == Enum.CreateOutfitFailure.OutfitLimitReached then
-- 告訴用戶他們達到了服裝上限
elseif failureType == Enum.CreateOutfitFailure.InvalidName then
-- 告訴用戶選擇不同的名稱
else -- Enum.CreateOutfitFailure.Other
-- 一般失敗;重試或顯示一般錯誤
end
end
end)Prompt Delete Outfit Completed
參數
Prompt Rename Outfit Completed
參數
Prompt Save Avatar Completed
Avatar Editor Service. Prompt Save Avatar Completed(
參數
Prompt Set Favorite Completed
參數
Prompt Update Outfit Completed
參數