27 lines
516 B
GDScript
27 lines
516 B
GDScript
extends Node
|
|
|
|
signal message_sent(message: String)
|
|
|
|
var input_thread: Thread
|
|
var stop: bool = false
|
|
|
|
|
|
func _enter_tree() -> void:
|
|
input_thread = Thread.new()
|
|
input_thread.start(_process_input)
|
|
|
|
|
|
func _exit_tree() -> void:
|
|
stop = true
|
|
input_thread.wait_to_finish()
|
|
|
|
|
|
func _process_input() -> void:
|
|
var text := ""
|
|
while not stop and text != "quit":
|
|
text = OS.read_string_from_stdin().strip_edges()
|
|
if text and Referencer.chat:
|
|
print("Inserted text: ", text)
|
|
message_sent.emit(text)
|
|
print("STOPPING!")
|