Skip to reading
Text & Sierra-Style Adventures

A2. Controller source: lines 36-70

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

Finding live GUI controls and maintaining the transcript reader.

Code example
        var field: LineEdit = control(element_id) as LineEdit
        if is_instance_valid(field):
            if not field.text_submitted.is_connected(send):
                field.text_submitted.connect(send)
    var reader: TextEdit = control("story_transcript") as TextEdit
    if is_instance_valid(reader):
        reader.editable = false
        reader.add_theme_color_override("font_readonly_color",
            Color("ecdfbf"))
        var body: String = "\n\n".join(
            Runtime.variables.get("ta_lines", []))
        if reader.text != body:
            reader.text = body
            reader.set_deferred("scroll_vertical",
                reader.get_line_count())
    sync_view()
    sync_world()
Code example
func text_mode() -> bool:
    return bool(Runtime.variables.get("ta_text_mode", true))
Code example
func sync_view() -> void:
    var signature: String = str(text_mode())
    if signature == screen_signature:
        return
    screen_signature = signature
    Runtime.set_player_input_enabled(not text_mode())
    Runtime.hide_gui("reply_card")
    pending_reply = false
    Runtime.show_gui("text_screen" if text_mode() else "graph_hud")
    Runtime.hide_gui("graph_hud" if text_mode() else "text_screen")
    if text_mode():
        call_deferred("focus_command")
Code example
func sync_world() -> void:

Continue directly with the next source block.

Page 55 of 68Permalink
Go to page