Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I check if a decal has loaded?

I've found a 4 year old scripting helpers post that says how to, but I have a problem.

You can go this link to learn more information about it: http://wiki.roblox.com/index.php?title=API:Class/ContentProvider/Preload I hope this helps.

Now, this is a part from the solution of the question. And when I went to the link, it says it's deprecated. I saw PreloadAsync is the replacement, but I am not sure how I would use it, so when you're making a response, please provide an example, because I am very confused about how to use it. I've also seen the example in the PreloadAsync page, but I am still confused. Anyways that's all!

1 answer

✓ Accepted answer

The PreloadAsync function loads multiple decals at once rather then the old Preload which in tern only loaded the decals 1 by 1

I've re-written the code from the PreloadAsync page from the page you specified, Hopefully its a little clearer on how to use the new Async preload function.

Note: the table below in the code isn't required to use PreloadAsync function its just a way to set a flag (true/false) when the decal has loaded or not you can use a simple table like:

local ContentProvider = game:GetService("ContentProvider")
local Decals = {
	"rbxassetid://1234561",
	"rbxassetid://1234562"
}

local function getStatus(contentId, status)
	if(status == Enum.AssetFetchStatus.Success) then
		print(contentId.." Loaded!")
	end
end
     
ContentProvider:PreloadAsync(Decals , getStatus)

Might be a better format:

local ContentProvider = game:GetService("ContentProvider")
local Decals = {
	{
		DecalID = "rbxassetid://1234561",
		Loaded = false
	},
	{
		DecalID = "rbxassetid://1234565",
		Loaded = false
	}
}
local DecTble = {}
for k,v in pairs(Decals) do
	DecTble[k] = v.DecalID
end

local function getStatus(contentId, status,Table)
	if(status == Enum.AssetFetchStatus.Success) then
		Table.Loaded = true
	end
end
     
for k,v in pairs(Decals) do
	ContentProvider:PreloadAsync(DecTble, function(contentId, status) getStatus(contentId, status,v) end)
end

for k,v in pairs(Decals) do
	print("[",k,"] Decal = [",v.DecalID,"] Loaded = [",v.Loaded,"]")
end

Hope this helps! :)

1 comment

1

Alr, thank you for the answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.