0 votes

Have a text display event, simple RPG style that shows text when you're in an area and press a button. However, when the event is first called, it takes two button presses to start. After that, provided the scene has not changed, it only takes one button press. I am using a textbox object that is instanced with custom functions but this works fine in the other events I have made. I think I've been looking at it too long and wonder what I am missing. It has to be something in the Input section that I am certain will be disappointingly obvious once I see it. XD

    extends Area2D

### open event flag and objects
var _can_search = false
onready var _look = $LookSprite
onready var _run = $RunSprite

### text values and state
onready var _textbox = $TextAnimation
onready var _dialog = $TextAnimation/Label
export var _textLine1 : String
export var _textLine2 : String
export var _textLine3 : String
export var _textLine4 : String
var _textsArray = [_textLine1,_textLine2,_textLine3,_textLine4]
var _nextText = _textLine1
const _EMPTY = ''

### make text invisible at boot (visible in editor)
func _ready():
    _look.visible = false

### input command
func _input(_event):
    if _can_search:
        if Input.is_action_just_pressed("_interact"):

### pull from array and display, if it's empty, exit.
func _displayed():
    _look.visible = false
    _nextText = _textsArray.pop_front()

    if _nextText != _EMPTY:
        DirectorNode._freezePlayer = true
        DirectorNode._freezePlayer = false
        _textsArray = [_textLine1,_textLine2,_textLine3,_textLine4]

func _on_SearchEvent_body_entered(body):
    if body.name == 'Lydia':
        if DirectorNode._chaseMode == false:
            _can_search = true
            _look.visible = true
        else: ### disable event if pursued!
            _can_search = false
            _look.visible = false
            _run.visible = true

func _on_SearchEvent_body_exited(body):
    if body.name == 'Lydia':
        _can_search = false
        _look.visible = false
        _run.visible = false
Godot version Godot 3.5 stable
in Engine by (548 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.