46. Resources, load and preload
const ADVENTURE_BASE = preload("res://scripts/runtime/script_base.gd")func run() -> bool:
var script_resource: Resource = load("res://scripts/runtime/script_base.gd")
return script_resource == ADVENTURE_BASEpreload requires a constant path and loads while the script is prepared. load/ResourceLoader.load can use a runtime path. A .gd resource is a Script; call new to make its instance. A PackedScene uses instantiate instead.
res:// points to the resource pack/project of the application currently running. In PCA’s editor that is the PCA application; in a built game it is the runner and mounted game content. A script record ID is not a file at res://scripts/your_id.gd.
ResourceLoader.exists can check a resource path before load. After loading, check the actual type. For raw packaged text/data, include the file through the export workflow; imported resources may have a converted format.
Figure 15. Imported asset metadata and Godot resource paths are different from the visible asset name.
