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