From 8c20e1de5403d70e241e1c932d76d503cc3dfda7 Mon Sep 17 00:00:00 2001 From: Max G Date: Mon, 6 Jan 2020 03:11:05 -0600 Subject: [PATCH] Fixed stack alignment. --- Shared/AssetUtil.lua | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/Shared/AssetUtil.lua b/Shared/AssetUtil.lua index 38de2a2..9ff0a92 100644 --- a/Shared/AssetUtil.lua +++ b/Shared/AssetUtil.lua @@ -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 \ No newline at end of file +return AssetUtil