Newbie trying to understand Background loading example code

zickeryzickery Posts: 1Member

First of all, am a newbie in both programming and Godot.
Was skimming through the tutorial and got to background_loading.
In it was the code at near the end
Need explanation on a few things to help understand the code.
1. ResourceLoader.has found in the method queue_resource

func queue_resource(path, p_in_front = false):
    if path in pending:
    elif ResourceLoader.has(path):
        var res = ResourceLoader.load(path)
        pending[path] = res
        var res = ResourceLoader.load_interactive(path)
        res.set_meta("path", path)
        if p_in_front:
            queue.insert(0, res)
        pending[path] = res

Since ResourceLoader.has is deprecated, I don't know which method between ResourceLoader.exists and ResourceLoader.has_cached I should use to replace it. On top of this, I don't know what any of these methods do.
I hope someone can explain the result of these methods in terms of the 3 stages of loading.

  • not start loading yet
  • loading in progress
  • has loaded (and cached ... maybe)
  1. VisualServer.sync() in the method _wait_for_resource
    My limited understanding is that VisualServer is a thingy that draws things. My guess is that sync() method is meant to wait for resource to finish loading (in its thread) before VisualServer starts drawing. My question is when does VisualServer stop sync(), since game thread is always running.

More in-depth explanation of all the above is more than welcome, thanks. Also, how to type codes in forum? I used the code and pre element but the text is still all in black.


  • joel127joel127 Posts: 18Member


    If you are a newbie, I would advice to not use multiple threads to load.

    I'm an experienced programmer and I still was getting random crash of my game. After being unable to fix the issue for a long time, I switched to interactive loading (loading in the main thread) and found out it produced less lag and was not crashing my game.

    Hope it helps.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file