Skip to reading
GDScript Programming & Godot

24. Find records through registries

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView illustrations
Code example
func run() -> String:
    var door: Variant = Objects.Get("archive_door")
    if door == null or not door.Exists():
        return "Door is missing"
    var title: String = str(door.Get("name", "Door"))
    Log(title)
    return title

The main registries are Character, Scene, Objects, Asset, Inventory, Cursor, Verb, GUI, Dialogue, Quest, Variable, Fonts and Cutscene. Script registries cover the supported languages. Project and Settings provide project-level data; Global provides script-call proxies.

Use Get when the ID is in a string, contains punctuation or might collide with an inherited method.

Objects.archive_door is a convenient direct spelling for a simple ID. Registry IDs and display names serve different purposes; use stable IDs in calls.

Figure 8. Registry-aware completion helps choose a record rather than guessing a display label.

PCA’s registries are separate from Godot’s SceneTree. Scene.lab is room data. get_tree().current_scene is the loaded top-level Godot scene, which can be the PCA editor or runner.

Page 33 of 378Permalink
Go to page