From df0215a8abdba6be32fc99027f2ce6cae5a7df3c Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Fri, 25 Sep 2020 10:40:38 +0200 Subject: [PATCH] Refer to child nodes via their path in code directly This helps making the scene self-contained. --- main.gd | 30 ++++++++---------------------- main.tscn | 8 -------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/main.gd b/main.gd index a08faee..1e93f0a 100644 --- a/main.gd +++ b/main.gd @@ -6,30 +6,16 @@ var dragged = null var level_set = "bottom-up" var current_level = 0 -export(NodePath) var terminal_path -onready var terminal = get_node(terminal_path) +onready var terminal = $HBoxContainer/RightSide/Terminal onready var input = terminal.input onready var output = terminal.output - -export(NodePath) var goal_repository_path_2 -export(NodePath) var active_repository_path_2 -onready var goal_repository = get_node(goal_repository_path_2) -onready var active_repository = get_node(active_repository_path_2) - -export(NodePath) var level_select_path -onready var level_select = get_node(level_select_path) - -export(NodePath) var next_level_button_path -onready var next_level_button = get_node(next_level_button_path) - -export(NodePath) var level_name_path -onready var level_name = get_node(level_name_path) - -export(NodePath) var level_description_path -onready var level_description = get_node(level_description_path) - -export(NodePath) var level_congrats_path -onready var level_congrats = get_node(level_congrats_path) +onready var goal_repository = $HBoxContainer/Repositories/GoalRepository +onready var active_repository = $HBoxContainer/Repositories/ActiveRepository +onready var level_select = $HBoxContainer/RightSide/TopStuff/Menu/LevelSelect +onready var next_level_button = $HBoxContainer/RightSide/TopStuff/Menu/NextLevelButton +onready var level_name = $HBoxContainer/RightSide/TopStuff/LevelPanel/LevelName +onready var level_description = $HBoxContainer/RightSide/TopStuff/LevelPanel/Text/LevelDescription +onready var level_congrats = $HBoxContainer/RightSide/TopStuff/LevelPanel/Text/LevelCongrats func _ready(): # Initialize level select. diff --git a/main.tscn b/main.tscn index 7e88fc5..cac3218 100644 --- a/main.tscn +++ b/main.tscn @@ -29,14 +29,6 @@ script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": false } -terminal_path = NodePath("HBoxContainer/RightSide/Terminal") -goal_repository_path_2 = NodePath("HBoxContainer/Repositories/GoalRepository") -active_repository_path_2 = NodePath("HBoxContainer/Repositories/ActiveRepository") -level_select_path = NodePath("HBoxContainer/RightSide/TopStuff/Menu/LevelSelect") -next_level_button_path = NodePath("HBoxContainer/RightSide/TopStuff/Menu/NextLevelButton") -level_name_path = NodePath("HBoxContainer/RightSide/TopStuff/LevelPanel/LevelName") -level_description_path = NodePath("HBoxContainer/RightSide/TopStuff/LevelPanel/Text/LevelDescription") -level_congrats_path = NodePath("HBoxContainer/RightSide/TopStuff/LevelPanel/Text/LevelCongrats") [node name="Background" type="ColorRect" parent="."] anchor_right = 1.0