generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Free code: Preloader

Previous Thread :: Next Thread 
CrowClaws is not online. 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 is not online. 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 is not online. 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 is not online. gooey333
Joined: 24 Mar 2013
Total Posts: 1208
28 Jul 2015 12:28 AM
Hey timeticks! Do you make maps?
Report Abuse
TimeTicks is not online. 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 is not online. gooey333
Joined: 24 Mar 2013
Total Posts: 1208
28 Jul 2015 12:30 AM
Could u make me one?
Report Abuse
TimeTicks is not online. 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 is not online. gooey333
Joined: 24 Mar 2013
Total Posts: 1208
28 Jul 2015 12:33 AM
Sent you a friend req time
Report Abuse
TimeTicks is not online. 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 is not online. 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 is not online. gooey333
Joined: 24 Mar 2013
Total Posts: 1208
28 Jul 2015 12:41 AM
Hey time!
Report Abuse
CrowClaws is not online. 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 is not online. 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 is not online. 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 is not online. 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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
28 Jul 2015 05:53 PM
Roblox automatically preloads instances that are in the datamodel, so this is stupid.
Report Abuse
vydlv is not online. 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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
28 Jul 2015 05:57 PM
It's always worked this way, at least for a long time.
Report Abuse
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
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 is not online. 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 is not online. 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
nQqzRYVpIKA5jLP is not online. nQqzRYVpIKA5jLP
Joined: 05 Mar 2015
Total Posts: 4135
28 Jul 2015 06:11 PM
Yeah, but if it's in the datamodel, then obviously it's being used.
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
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 is not online. 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
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image