this post was submitted on 09 Oct 2023
13 points (100.0% liked)

Godot

6761 readers
6 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS
 

Why is there a load() at all?

top 5 comments
sorted by: hot top controversial new old
[–] GammaGames@beehaw.org 5 points 2 years ago (1 children)

In GDScript, there exists the global preload method. It loads resources as early as possible to front-load the "loading" operations and avoid loading resources while in the middle of performance-sensitive code.

Its counterpart, the load method, loads a resource only when it reaches the load statement. That is, it will load a resource in-place which can cause slowdowns when it occurs in the middle of sensitive processes. The load() function is also an alias for ResourceLoader.load(path) which is accessible to all scripting languages.

From the docs: https://docs.godotengine.org/en/stable/tutorials/best_practices/logic_preferences.html

[–] jack@monero.town 3 points 2 years ago (1 children)

I somehow overlooked that in the docs, thanks!

[–] GammaGames@beehaw.org 3 points 2 years ago

Tbf it took a little digging to find, no worries!

[–] ICastFist@programming.dev 5 points 2 years ago (1 children)

For a personal project, I'm using load() because I don't know which file I'm supposed to load when the scene starts. Also, said file can change during game runtime.

In my case, I'm changing textures. With the game paused, the player can change some stuff, like the character's hair. I don't need to preload all of them, and maybe a preloaded one might not be the one that should actually be loaded in the end.

[–] jack@monero.town 2 points 2 years ago

Okay, that makes sense. Thank you