Skip to reading
Text & Sierra-Style Adventures

A3. Controller source: lines 71-105

Edition 0.86.3.4

Build a complete text or graphical parser adventure with typed commands, inventory puzzles and press-to-walk controls.

Download PDFView PDF page

Synchronizing the loose-item models with story state.

Code example
    if not Runtime.ready_for_input:
        return
    var signature: String = str([
        Runtime.scene_id, Runtime.entity_nodes.size(),
        Runtime.variables.get("ta_key_room"),
        Runtime.variables.get("ta_fuse_room"),
        Runtime.variables.get("ta_door_open")])
    if signature == world_signature:
        return
    world_signature = signature
    for item: String in ["key", "fuse"]:
        for room: String in ["lab", "cabin"]:
            Runtime.set_entity_visible(room + "_" + item,
                str(Runtime.variables.get("ta_" + item + "_room"))
                == room)
    Runtime.set_entity_visible("cabin_door",
        not bool(Runtime.variables.get("ta_door_open", false)))
Code example
func focus_command() -> void:
    var element_id: String = (
        "text_command" if text_mode() else "graph_command")
    var field: LineEdit = control(element_id) as LineEdit
    if is_instance_valid(field) and field.is_visible_in_tree():
        field.grab_focus()
        field.edit()
Code example
func _input(event: InputEvent) -> void:
    if not Runtime.active_system_gui_id.is_empty():
        return
    if Runtime.system_menu != null and Runtime.system_menu.is_open():
        return
    var key: InputEventKey = event as InputEventKey
    if key == null or not key.pressed or key.echo or busy:
        return
    var code: int = int(key.keycode)

Continue directly with the next source block.

Page 56 of 68Permalink
Go to page