Skip to reading
Eight Adventure Interface Workshops

Keep the sentence caption complete

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

Record ID: sentence_line. Global Script: on. This writes the pending pair/item prefix into the four named command Labels. Keep those Labels’ authored text simple; the script owns their live caption.

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func on_global_ready(_context: Dictionary = {}) -> void:
    process_priority = 100
    set_process(true)
Code example
func _process(_delta: float) -> void:
    if not is_instance_valid(Runtime):
        return
    var manager: Node = Runtime.get("authored_gui_manager")
    if not is_instance_valid(manager):
        return
    var prefix: String = str(Runtime.call("get_current_verb_display_name"))
    var pair: Variant = Runtime.get("preposition_interaction")
    if pair != null and pair.call("active"):
        prefix = str(pair.call("prefix"))
    elif not str(Runtime.get("selected_inventory")).is_empty():
        var item_id: String = str(Runtime.get("selected_inventory"))
        var item: Dictionary = Runtime.get("project").get_inventory(item_id)
        prefix = "Use " + str(item.get("name", item_id)) + " with"
    var caption: String = (prefix + " " + str(Runtime.get("current_hover_label"))).strip_edges()
    var nodes: Dictionary = manager.get("element_nodes")
    for label_id: String in ["zak_command", "dot_command", "mi_command", "curse_object_line"]:
        var host: Control = nodes.get(label_id) as Control
        var label: Label = host.get_node_or_null("Text") if is_instance_valid(host) else null
        if is_instance_valid(label) and label.is_visible_in_tree():
            label.text = caption

The Label element’s live control contains a Text child. This script updates that child; it does not rebuild the control or replace every word with a new GUI element.

Page 97 of 119Permalink
Go to page