Fixed stack alignment.

This commit is contained in:
Max G 2020-01-06 03:11:05 -06:00 committed by GitHub
parent accb6218ee
commit 8c20e1de54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 14 deletions

View File

@ -13,36 +13,37 @@ for _,assetType in pairs(Enum.AssetType:GetEnumItems()) do
assetTypes[assetType.Value] = assetType.Name
end
function AssetUtil:SafeCall(class,method,...)
local success,response
local tries = 0
function AssetUtil:SafeCall(class, method, ...)
local success, response
local tries = 0
while not success do
success, response = pcall(class[method], class, ...)
if not success then
if not success then
if response:find("400") then
success = true
response = false
else
tries = tries + 1
if tries > self.NUM_FETCH_RETRIES then
return false
end
end
end
end
end
return success, response
end
function AssetUtil:Import(assetId)
local success, model = self:SafeCall(InsertService, "LoadAsset", assetId)
local success, model = self:SafeCall(InsertService, "LoadAsset", assetId)
if success then
local objects = model:GetChildren()
return true, unpack(objects)
end
end
return false
end
@ -55,27 +56,29 @@ function AssetUtil:RequestImage(assetId)
if self.TextureCache[assetId] == nil then
local success, response = self:SafeCall(MarketplaceService, "GetProductInfo", assetId)
if success then
local result
local result
if response then
local assetType = assetTypes[response.AssetTypeId]
local assetType = assetTypes[response.AssetTypeId]
if assetType == "Image" then -- No transformation needed!
result = "rbxassetid://" .. assetId
elseif assetType == "TeeShirt" then
local imported,shirtGraphic = self:Import(assetId)
local imported, shirtGraphic = self:Import(assetId)
if imported then
result = shirtGraphic.Graphic
end
elseif assetType == "Decal" or assetType == "Face" then
local imported, decal = self:Import(assetId)
if imported then
result = decal.Texture
end
end
else
result = ""
end
end
self.TextureCache[assetId] = result
end
@ -84,4 +87,4 @@ function AssetUtil:RequestImage(assetId)
return true, self.TextureCache[assetId]
end
return AssetUtil
return AssetUtil