I am making an in-game console. I have the "Console Events" set up as their own scenes because they are visually and physically different.
In my main "Demo" scene I have the console input and output.
When I add a "Console Event" to the consol output, I want to edit the time text to the current system time and the message to reflect a what has happened in the game-world.
I instanciate the packed scene but when I try to edit the text of the label, I get the error of
"Invalid call. Nonexistent function 'get_child' in base 'PackedScene'."
My demo scene is this...
Level_Demo
-User_interface
My test output is this...
Test_Output_Margin_Box
-HBoxContainer
--Time_LABEL
--Message_LABEL
-outputinfo_bg
my code is simply this...
`
extends CanvasLayer
References
@onready var console: VBoxContainer = $TextureRect/Console
@onready var console_output: VBoxContainer = $TextureRect/Console/Console_Output
@onready var console_input: HBoxContainer = $TextureRect/Console/Console_Input
@onready var line_edit: LineEdit = $TextureRect/Console/Console_Input/LineEdit
@onready var texture_button: TextureButton = $TextureRect/Console/Console_Input/TextureButton
Events
var TEST_OUTPUT = preload("res://Scenes/Console_Outputs/single_line_output_message.tscn")
func _ready() -> void:
pass
func process(delta: float) -> void:
pass
func input(event: InputEvent) -> void:
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
add_console_event(TEST_OUTPUT)
pass
pass
func add_console_event(event: PackedScene):
event.find_child("Time_LABEL").text = Time.get_time_dict_from_system(false)
event.find_child("Message_LABEL").text = "I AM A TEST!"
console_output.add_child(event.instantiate())
pass
`
All I want to do is update the Text property of the Labels before it is inserted into the Console: VBox Container