0 votes

I'm trying to figure out a way to get godot to keep track of user input typing a word correctly. I'm really not sure on how to start about doing this, but I need a way to automatize this as this 'word' is supposed to be a random word among an array and I'm going to be having ideally 100+ words changing very fast as they're typed in.

Here's what I have now. Ideally the Timer is there to change the word when the user fails to complete it on time, but now I have it to test... Probably not the most necessary thing to include in this sample but as it has helped me understand how to get the values of $Label as it changes everytime

extends Control

var wordlist = ["one","two","three", "four"]
onready var current_word
var timer_word_time

func _ready():
    get_node("Timer").connect("timeout",self,"_on_Timer_timeout")
    #$Timer.start(timer_word_time)
    change_word()

func change_word():
    current_word = wordlist[randi() % wordlist.size()]
    get_node("LineEdit").placeholder_text = str(current_word)
    get_node("Label").text = str(current_word)
    timer_word_time = $Label.get_total_character_count()
    $Timer.start(timer_word_time)

func _on_Timer_timeout():
    change_word()

func _process(delta):
    get_node("Label2").text = str(int ($Timer.get_time_left()))
#just to show the remaining time on screen, also to help me

As of now, ideally the user should write the given word in LineEdit, and I want godot to reset the progress of typing if the user gets one word wrong, and validate it if the user gets the whole word right.

I'm imagining I should be doing something with _process(delta) but I'm... very lost at this point. I'm really still learning, I'm probably missing something really obvious too haha

asked Apr 2, 2019 in Engine by reinapepiada (12 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 How to use this Q&A? before posting your first questions.