CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 28 Jul 2015 12:08 AM |
local properties = { ["Sound"] = "SoundId", ["ImageLabel"] = "Image", ["ImageButton"] = "Image", ["Decal"] = "Texture" } local function pre(cont) for i,v in next, cont:GetChildren() do pcall(function() for ii,vv in next, properties do pcall(function() if v:IsA(ii) then game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. v[vv]) end end) end if #v:GetChildren() > 0 then pre(v) end end) end end pcall(function() pre(game) end)
enjoy |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 28 Jul 2015 12:15 AM |
STOP USING PCALL. HORRIBLE
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 28 Jul 2015 12:18 AM |
| He has to use pcall since he is calling a recursive function on game, it's to handle the possibility of attempting to index objects that are roblox locked. |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 28 Jul 2015 12:28 AM |
| Hey timeticks! Do you make maps? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 28 Jul 2015 12:29 AM |
Yes
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 28 Jul 2015 12:31 AM |
pm me
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 28 Jul 2015 12:33 AM |
| Sent you a friend req time |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 28 Jul 2015 12:37 AM |
pm me
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 28 Jul 2015 12:38 AM |
| Time, please unlock ur inbox so I can pm u |
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
| |
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 28 Jul 2015 05:28 PM |
I have to use pcall because if i am cycling through the whole game i will hit roblox locked things and eventully might hit some oddly loaded things and bugs. It's just safe.
|
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 28 Jul 2015 05:29 PM |
cycling the entire game is so inefficient. Instead of being so danm lazy, put all the ids in table and preload them.
"Talk is cheap. Show me the code." - Linus Torvalds |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 28 Jul 2015 05:35 PM |
Oh hod the inefficiency. You love making hundreds of closures don't you... don't use pcall here, just use a simpke table and some conditional statements |
|
|
| Report Abuse |
|
|
vydlv
|
  |
| Joined: 08 Jun 2010 |
| Total Posts: 1517 |
|
|
| 28 Jul 2015 05:52 PM |
local ContentProvider = Game:GetService("ContentProvider") local function LoadAssets(AssetList) -- Takes an asset list and preloads it. Will not wait for them to load. for _, AssetId in pairs(AssetList) do ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. AssetId) end end LoadAssets({2253543, 2434541, 5133543, 2423433, 41143243, 2453865, 21433365, 2154549})
yes i did just take this straight from the wiki |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2015 05:53 PM |
| Roblox automatically preloads instances that are in the datamodel, so this is stupid. |
|
|
| Report Abuse |
|
|
vydlv
|
  |
| Joined: 08 Jun 2010 |
| Total Posts: 1517 |
|
|
| 28 Jul 2015 05:55 PM |
| ^ Is that a relatively new feature? Haven't heard of it |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2015 05:57 PM |
| It's always worked this way, at least for a long time. |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2015 05:58 PM |
| Well, yeah it's always worked this way. Why would they not load the content in your game, then images would not be displayed and that just wouldn't make any sense. |
|
|
| Report Abuse |
|
|
Tokimonu
|
  |
| Joined: 18 Sep 2009 |
| Total Posts: 643 |
|
|
| 28 Jul 2015 06:06 PM |
I always just use this:
local ContentProvider = Game:GetService("ContentProvider") -- load a bunch of assets local assets = {2253543, 2434541, 5133543, 2423433} for _, asset in ipairs(assets) do ContentProvider:Preload("http://www.roblox.com/asset/?id=" .. asset) end -- wait for them to complete while ContentProvider.RequestQueueSize > 0 do wait(0.1) end
from http://wiki.roblox.com/index.php?title=API:Class/ContentProvider
I don't know, I just like it better in my opinion, but thanks for releasing it to others!
[ insert neat siggy here ] |
|
|
| Report Abuse |
|
|
vydlv
|
  |
| Joined: 08 Jun 2010 |
| Total Posts: 1517 |
|
|
| 28 Jul 2015 06:06 PM |
Then what's the point of the Preload function?
wiki says " Usually, content is loaded only when it starts being used ... Preload is used to load this content beforehand, so that it works instantly."
but idk if preload was made before or something |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2015 06:11 PM |
| Yeah, but if it's in the datamodel, then obviously it's being used. |
|
|
| Report Abuse |
|
|
|
| 28 Jul 2015 06:18 PM |
game.ContentProvider:PreloadAsync({91912333,224343,346456456,6465456});
"If you are good at something, never do it for free." - The Joker |
|
|
| Report Abuse |
|
|
CrowClaws
|
  |
| Joined: 04 Jul 2010 |
| Total Posts: 4466 |
|
|
| 29 Jul 2015 08:35 PM |
| but what if you have liek hunderds of assets |
|
|
| Report Abuse |
|
|
|
| 29 Jul 2015 08:41 PM |
sad to say, but this has already been done http://www.roblox.com/Load-Ids-Module-item?id=244840099
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|