Skip to reading
Replace the Built-in Screens

Personal notebook controller - part 2 of 3

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 PDF page
Code example
func render() -> void:
    if not is_instance_valid(Runtime):
        return
    var values: Dictionary = Runtime.get("variables")
    var actor: String = ActivePlayer()
    var selected: String = str(values.get("journal_choice", ""))
    previous = actor + "|" + selected
    var body: String = "Choose an entry to read it."
    var entries: Array = values.get("journal_" + actor, [])
    for entry: Dictionary in entries:
        if str(entry.get("id", "")) == selected:
            body = str(entry.get("text", "")) + "\n\n" + str(entry.get("body", ""))
            break
    var manager: Node = Runtime.get("authored_gui_manager")
    if not is_instance_valid(manager):
        return
    var nodes: Dictionary = manager.get("element_nodes")
    for owner: String in ["tester", "assistant"]:
        var reader: TextEdit = nodes.get(owner + "_journal_body") as TextEdit
        if not is_instance_valid(reader):
            continue
        reader.editable = false
        if owner == actor:
            reader.text = body

The reader displays the selected entry’s title and body. Its editing is disabled, while normal scrolling remains available. A character with no selected entry gets a plain instruction instead of another character’s previous text.

The owner list contains tester and assistant. Extend it, and create the matching reader IDs, when adding more playable characters.

Page 79 of 88Permalink
Go to page