Can anyone explain how this preloading is done?

Hi, I recently was playing a really nice optimized and cleaned game “Rivals” and when I checked the console, the preloading was pretty neat. It didn’t just load parts, it waited for the modules to be preloaded too. I use knit too and I’m wondering how this is done?

How do they know when the controllers are loaded and the time it took to load?

They probably used either tick() or os.clock() for the time.

The module probably looked like this

local t0 = os.clock()

local module = {}
-- module functions, classes, and controllers


print(`[{os.clock() - t0}ms] {script.Name}`)
return module
1 Like

So when the engine reaches the end is when the module is fully loaded?

I think so.

1 Like

In my custom system (I don’t use knit), once the module is done initializing, it prints to the console the elapsed time it took to load said module.

And format string is just to lessen the decimals from the tick calculations:

local FormatString = "%.5fs"

The result (my system is on both client and server):

I just realized Knit has a KnitInit Function you can add that fires when the controller is initilized. I’m thinking I can probably do the same thing you did in the Knit Framewrok by just tweaking it and not having to add the KnitInit function. Thank you.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.