Newbie trying to understand Background loading example code
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 resource_queue.gd.
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): _lock("queue_resource") if path in pending: _unlock("queue_resource") return elif ResourceLoader.has(path): var res = ResourceLoader.load(path) pending[path] = res _unlock("queue_resource") return else: var res = ResourceLoader.load_interactive(path) res.set_meta("path", path) if p_in_front: queue.insert(0, res) else: queue.push_back(res) pending[path] = res _post("queue_resource") _unlock("queue_resource") return
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)
- 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.