Skip to reading
Text & Sierra-Style Adventures

A5. Controller source: lines 141-175

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

Command submission and text cleanup.

Code example
func dismiss_reply() -> void:
    pending_reply = false
    Runtime.hide_gui("reply_card")
    var focused: Control = get_viewport().gui_get_focus_owner()
    if focused != null:
        focused.release_focus()
    if text_mode():
        focus_command()
Code example
func presentation() -> void:
    Runtime.variables["ta_text_mode"] = not text_mode()
    screen_signature = ""
    sync_view()
    Runtime.state_changed()
Code example
func run() -> void:
    await send(str(context.get("command", "help")))
Code example
func send(command: String) -> void:
    if busy or pending_reply:
        return
    var cleaned: String = clean(command)
    if cleaned.is_empty():
        return
    busy = true
    Runtime.variables["ta_last"] = command
    for element_id: String in ["text_command", "graph_command"]:
        var field: LineEdit = control(element_id) as LineEdit
        if is_instance_valid(field):
            field.clear()
            if not text_mode():
                field.release_focus()
    append_line("> " + command.strip_edges())
    await execute_command(cleaned)
    Runtime.state_changed()

Continue directly with the next source block.

Page 58 of 68Permalink
Go to page