Skip to content

Commit 6a11ebe

Browse files
committed
Block: Handle bottom_snap property directly
Godot knows how to serialize a reference to a node directly, so there's no need to store a path and restore the node manually. This is clearer, but it also means that bottom_snap can be used without waiting for it the Block to be ready.
1 parent 8b41b8d commit 6a11ebe

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

addons/block_code/ui/blocks/block/block.gd

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ signal modified
2121
@export var category: String
2222

2323
## The next block in the line of execution (can be null if end)
24-
@export var bottom_snap_path: NodePath
24+
@export var bottom_snap: SnapPoint
2525

2626
## The scope of the block (statement of matching entry block)
2727
@export var scope: String = ""
2828

29-
var bottom_snap: SnapPoint
30-
3129

3230
func _ready():
33-
bottom_snap = get_node_or_null(bottom_snap_path)
3431
mouse_filter = Control.MOUSE_FILTER_IGNORE
3532

3633

addons/block_code/ui/blocks/control_block/control_block.tscn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
[ext_resource type="Script" path="res://addons/block_code/ui/blocks/control_block/control_block.gd" id="1_2hbir"]
44
[ext_resource type="PackedScene" uid="uid://b1oge52xhjqnu" path="res://addons/block_code/ui/blocks/utilities/snap_point/snap_point.tscn" id="3_nhryi"]
55

6-
[node name="ControlBlock" type="MarginContainer"]
6+
[node name="ControlBlock" type="MarginContainer" node_paths=PackedStringArray("bottom_snap")]
77
size_flags_horizontal = 0
88
mouse_filter = 2
99
script = ExtResource("1_2hbir")
1010
block_name = "control_block"
1111
label = "Control Block"
1212
color = Color(0.59979, 0.536348, 0.876215, 1)
13-
bottom_snap_path = NodePath("VBoxContainer/SnapPoint")
13+
bottom_snap = NodePath("VBoxContainer/SnapPoint")
1414

1515
[node name="VBoxContainer" type="VBoxContainer" parent="."]
1616
layout_mode = 2

addons/block_code/ui/blocks/statement_block/statement_block.tscn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
[ext_resource type="PackedScene" uid="uid://c7puyxpqcq6xo" path="res://addons/block_code/ui/blocks/utilities/drag_drop_area/drag_drop_area.tscn" id="2_owgdx"]
66
[ext_resource type="PackedScene" uid="uid://b1oge52xhjqnu" path="res://addons/block_code/ui/blocks/utilities/snap_point/snap_point.tscn" id="3_5vaov"]
77

8-
[node name="StatementBlock" type="MarginContainer"]
8+
[node name="StatementBlock" type="MarginContainer" node_paths=PackedStringArray("bottom_snap")]
99
size_flags_horizontal = 0
1010
mouse_filter = 2
1111
script = ExtResource("1_6wvlf")
1212
block_name = "statement_block"
1313
label = "StatementBlock"
14-
bottom_snap_path = NodePath("VBoxContainer/SnapPoint")
14+
bottom_snap = NodePath("VBoxContainer/SnapPoint")
1515

1616
[node name="VBoxContainer" type="VBoxContainer" parent="."]
1717
layout_mode = 2

0 commit comments

Comments
 (0)