diff --git a/addons/block_code/block_definition.gd b/addons/block_code/block_definition.gd new file mode 100644 index 00000000..e8ba7027 --- /dev/null +++ b/addons/block_code/block_definition.gd @@ -0,0 +1,21 @@ +extends Resource + +const Types = preload("res://addons/block_code/types/types.gd") + +var name: StringName +var type: Types.BlockType +var description: String +var category: String + +var label_template: String +var code_template: String +var defaults: Dictionary = {} + +## Only for blocks of type Types.ENTRY. If non-empty, this block defines a +## callback that will be connected to the signal with this name. +var signal_name: String = "" + + +func _init(p_name: StringName, p_type: Types.BlockType): + name = p_name + type = p_type diff --git a/addons/block_code/blocks_catalog.gd b/addons/block_code/blocks_catalog.gd new file mode 100644 index 00000000..8593ff71 --- /dev/null +++ b/addons/block_code/blocks_catalog.gd @@ -0,0 +1,35 @@ +extends Object + +const BlockDefinition = preload("res://addons/block_code/block_definition.gd") +const Types = preload("res://addons/block_code/types/types.gd") + +static var _catalog: Dictionary + + +static func setup(): + if _catalog: + return + + _catalog = {} + var block_definition: BlockDefinition = BlockDefinition.new(&"ready_block", Types.BlockType.ENTRY) + block_definition.label_template = "On Ready" + block_definition.code_template = "func _ready():" + block_definition.description = 'Attached blocks will be executed once when the node is "ready"' + block_definition.category = "Lifecycle" + _catalog[&"ready_block"] = block_definition + + block_definition = BlockDefinition.new(&"print", Types.BlockType.EXECUTE) + block_definition.label_template = "print {text: STRING}" + block_definition.code_template = "print({text})" + block_definition.defaults = {"text": "Hello"} + block_definition.description = "Print the text to output" + block_definition.category = "Log" + _catalog[&"print"] = block_definition + + +static func get_block(block_name: StringName): + return _catalog.get(block_name) + + +static func has_block(block_name: StringName): + return block_name in _catalog diff --git a/addons/block_code/examples/pong_game/pong_game.tscn b/addons/block_code/examples/pong_game/pong_game.tscn index 52a983d9..fb71cd4f 100644 --- a/addons/block_code/examples/pong_game/pong_game.tscn +++ b/addons/block_code/examples/pong_game/pong_game.tscn @@ -7,90 +7,98 @@ [ext_resource type="Texture2D" uid="uid://tplpgtnfeda0" path="res://addons/block_code/examples/pong_game/assets/paddle.png" id="4_ra7bh"] [ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block.gd" id="5_wr38c"] [ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node_array.gd" id="6_ppdc3"] -[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/option_data.gd" id="7_1f578"] +[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/option_data.gd" id="7_3q6bj"] [ext_resource type="Script" path="res://addons/block_code/block_script_data/block_script_data.gd" id="7_uuuue"] [ext_resource type="PackedScene" uid="uid://c7l70grmkauij" path="res://addons/block_code/examples/pong_game/ball.tscn" id="9_xrqll"] [ext_resource type="PackedScene" uid="uid://fhoapg3anjsu" path="res://addons/block_code/examples/pong_game/goal_area.tscn" id="12_nqmxu"] [ext_resource type="Script" path="res://addons/block_code/simple_nodes/simple_scoring/simple_scoring.gd" id="13_tg3yk"] -[sub_resource type="Resource" id="Resource_7v74l"] +[sub_resource type="Resource" id="Resource_860cl"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "set_prop_speed"], ["label", "StatementBlock"], ["color", Color(0.647059, 0.694118, 0.760784, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set Speed to {value: VECTOR2}"], ["statement", "speed = {value}"], ["defaults", { -"value": "0,0" +serialized_props = [["block_name", &"set_prop_speed"], ["label", "StatementBlock"], ["color", Color(0.647059, 0.694118, 0.760784, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set Speed to {value: VECTOR2}"], ["statement", "speed = {value}"], ["defaults", { +"value": "0, 0" }], ["param_input_strings", { "value": "0,1000" }]] -[sub_resource type="Resource" id="Resource_trpau"] +[sub_resource type="Resource" id="Resource_q65fe"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_7v74l") +name = &"set_prop_speed" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_860cl") -[sub_resource type="Resource" id="Resource_g57b7"] +[sub_resource type="Resource" id="Resource_q1vhx"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "ready_block"], ["label", "EntryBlock"], ["color", Color(0.92549, 0.231373, 0.34902, 1)], ["block_type", 1], ["position", Vector2(75, 50)], ["scope", ""], ["block_format", "On Ready"], ["statement", "func _ready():"], ["defaults", {}], ["param_input_strings", {}], ["signal_name", ""]] +serialized_props = [["color", Color(0.92549, 0.231373, 0.34902, 1)], ["scope", ""], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_5atf0"] +[sub_resource type="Resource" id="Resource_yiq7s"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_g57b7") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_trpau")]] +name = &"ready_block" +position = Vector2(75, 175) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_q65fe")]] +serialized_block = SubResource("Resource_q1vhx") -[sub_resource type="Resource" id="Resource_ykx8c"] -script = ExtResource("7_1f578") +[sub_resource type="Resource" id="Resource_a45un"] +script = ExtResource("7_3q6bj") selected = 0 items = ["top-down", "platformer", "spaceship"] -[sub_resource type="Resource" id="Resource_rv265"] -script = ExtResource("7_1f578") +[sub_resource type="Resource" id="Resource_ldmk0"] +script = ExtResource("7_3q6bj") selected = 0 items = ["player_1", "player_2"] -[sub_resource type="Resource" id="Resource_rsniy"] -script = ExtResource("7_1f578") +[sub_resource type="Resource" id="Resource_604n7"] +script = ExtResource("7_3q6bj") selected = 0 items = ["top-down", "platformer", "spaceship"] -[sub_resource type="Resource" id="Resource_daqtm"] -script = ExtResource("7_1f578") +[sub_resource type="Resource" id="Resource_h8b8o"] +script = ExtResource("7_3q6bj") selected = 0 items = ["player_1", "player_2"] -[sub_resource type="Resource" id="Resource_ttufp"] +[sub_resource type="Resource" id="Resource_d3xtc"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "simplecharacter_move"], ["label", "StatementBlock"], ["color", Color(0.835294, 0.262745, 0.133333, 1)], ["block_type", 2], ["position", Vector2(-44, -18)], ["scope", ""], ["block_format", "Move with {player: OPTION} buttons as {kind: OPTION}"], ["statement", "move_with_player_buttons(\"{player}\", \"{kind}\", delta)"], ["defaults", { -"kind": SubResource("Resource_ykx8c"), -"player": SubResource("Resource_rv265") +serialized_props = [["block_name", &"simplecharacter_move"], ["label", "StatementBlock"], ["color", Color(0.835294, 0.262745, 0.133333, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Move with {player: OPTION} buttons as {kind: OPTION}"], ["statement", "move_with_player_buttons(\"{player}\", \"{kind}\", delta)"], ["defaults", { +"kind": SubResource("Resource_a45un"), +"player": SubResource("Resource_ldmk0") }], ["param_input_strings", { -"kind": SubResource("Resource_rsniy"), -"player": SubResource("Resource_daqtm") +"kind": SubResource("Resource_604n7"), +"player": SubResource("Resource_h8b8o") }]] -[sub_resource type="Resource" id="Resource_24g32"] +[sub_resource type="Resource" id="Resource_7x3sw"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_ttufp") +name = &"simplecharacter_move" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_d3xtc") -[sub_resource type="Resource" id="Resource_jjdkl"] +[sub_resource type="Resource" id="Resource_x6ddv"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "process_block"], ["label", "EntryBlock"], ["color", Color(0.92549, 0.231373, 0.34902, 1)], ["block_type", 1], ["position", Vector2(75, 175)], ["scope", ""], ["block_format", "On Process"], ["statement", "func _process(delta):"], ["defaults", {}], ["param_input_strings", {}], ["signal_name", ""]] +serialized_props = [["block_name", &"process_block"], ["label", "EntryBlock"], ["color", Color(0.92549, 0.231373, 0.34902, 1)], ["block_type", 1], ["position", Vector2(75, 300)], ["scope", ""], ["block_format", "On Process"], ["statement", "func _process(delta):"], ["defaults", {}], ["param_input_strings", {}], ["signal_name", ""]] -[sub_resource type="Resource" id="Resource_oxdce"] +[sub_resource type="Resource" id="Resource_0m462"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_jjdkl") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_24g32")]] +name = &"process_block" +position = Vector2(75, 300) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_7x3sw")]] +serialized_block = SubResource("Resource_x6ddv") -[sub_resource type="Resource" id="Resource_lwf35"] +[sub_resource type="Resource" id="Resource_a04yd"] script = ExtResource("6_ppdc3") -array = Array[ExtResource("4_qtggh")]([SubResource("Resource_5atf0"), SubResource("Resource_oxdce")]) +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_yiq7s"), SubResource("Resource_0m462")]) -[sub_resource type="Resource" id="Resource_dhvli"] +[sub_resource type="Resource" id="Resource_m2svk"] script = ExtResource("7_uuuue") script_inherits = "SimpleCharacter" -block_trees = SubResource("Resource_lwf35") +block_trees = SubResource("Resource_a04yd") variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) generated_script = "extends SimpleCharacter @@ -104,84 +112,92 @@ func _process(delta): " version = 0 -[sub_resource type="Resource" id="Resource_sfqsw"] +[sub_resource type="Resource" id="Resource_isc56"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "set_prop_speed"], ["label", "StatementBlock"], ["color", Color(0.647059, 0.694118, 0.760784, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set Speed to {value: VECTOR2}"], ["statement", "speed = {value}"], ["defaults", { -"value": "0,0" +serialized_props = [["block_name", &"set_prop_speed"], ["label", "StatementBlock"], ["color", Color(0.647059, 0.694118, 0.760784, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set Speed to {value: VECTOR2}"], ["statement", "speed = {value}"], ["defaults", { +"value": "0, 0" }], ["param_input_strings", { "value": "0,1000" }]] -[sub_resource type="Resource" id="Resource_iax81"] +[sub_resource type="Resource" id="Resource_ttkrd"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_sfqsw") +name = &"set_prop_speed" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_isc56") -[sub_resource type="Resource" id="Resource_weya7"] +[sub_resource type="Resource" id="Resource_06s7w"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "ready_block"], ["label", "EntryBlock"], ["color", Color(0.92549, 0.231373, 0.34902, 1)], ["block_type", 1], ["position", Vector2(-400, -75)], ["scope", ""], ["block_format", "On Ready"], ["statement", "func _ready():"], ["defaults", {}], ["param_input_strings", {}], ["signal_name", ""]] +serialized_props = [["color", Color(0.92549, 0.231373, 0.34902, 1)], ["scope", ""], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_bfsko"] +[sub_resource type="Resource" id="Resource_hrubs"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_weya7") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_iax81")]] +name = &"ready_block" +position = Vector2(50, 175) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_ttkrd")]] +serialized_block = SubResource("Resource_06s7w") -[sub_resource type="Resource" id="Resource_wv5rg"] -script = ExtResource("7_1f578") +[sub_resource type="Resource" id="Resource_y2msu"] +script = ExtResource("7_3q6bj") selected = 0 items = ["top-down", "platformer", "spaceship"] -[sub_resource type="Resource" id="Resource_r4lu4"] -script = ExtResource("7_1f578") +[sub_resource type="Resource" id="Resource_wq8lu"] +script = ExtResource("7_3q6bj") selected = 0 items = ["player_1", "player_2"] -[sub_resource type="Resource" id="Resource_qhieq"] -script = ExtResource("7_1f578") +[sub_resource type="Resource" id="Resource_cqi0p"] +script = ExtResource("7_3q6bj") selected = 0 items = ["top-down", "platformer", "spaceship"] -[sub_resource type="Resource" id="Resource_mjeck"] -script = ExtResource("7_1f578") +[sub_resource type="Resource" id="Resource_1apud"] +script = ExtResource("7_3q6bj") selected = 1 items = ["player_1", "player_2"] -[sub_resource type="Resource" id="Resource_rag8u"] +[sub_resource type="Resource" id="Resource_bl8w1"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "simplecharacter_move"], ["label", "StatementBlock"], ["color", Color(0.835294, 0.262745, 0.133333, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Move with {player: OPTION} buttons as {kind: OPTION}"], ["statement", "move_with_player_buttons(\"{player}\", \"{kind}\", delta)"], ["defaults", { -"kind": SubResource("Resource_wv5rg"), -"player": SubResource("Resource_r4lu4") +serialized_props = [["block_name", &"simplecharacter_move"], ["label", "StatementBlock"], ["color", Color(0.835294, 0.262745, 0.133333, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Move with {player: OPTION} buttons as {kind: OPTION}"], ["statement", "move_with_player_buttons(\"{player}\", \"{kind}\", delta)"], ["defaults", { +"kind": SubResource("Resource_y2msu"), +"player": SubResource("Resource_wq8lu") }], ["param_input_strings", { -"kind": SubResource("Resource_qhieq"), -"player": SubResource("Resource_mjeck") +"kind": SubResource("Resource_cqi0p"), +"player": SubResource("Resource_1apud") }]] -[sub_resource type="Resource" id="Resource_4a0ls"] +[sub_resource type="Resource" id="Resource_enqe8"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_rag8u") +name = &"simplecharacter_move" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_bl8w1") -[sub_resource type="Resource" id="Resource_m3ow7"] +[sub_resource type="Resource" id="Resource_3wgnl"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "process_block"], ["label", "EntryBlock"], ["color", Color(0.92549, 0.231373, 0.34902, 1)], ["block_type", 1], ["position", Vector2(-400, 50)], ["scope", ""], ["block_format", "On Process"], ["statement", "func _process(delta):"], ["defaults", {}], ["param_input_strings", {}], ["signal_name", ""]] +serialized_props = [["block_name", &"process_block"], ["label", "EntryBlock"], ["color", Color(0.92549, 0.231373, 0.34902, 1)], ["block_type", 1], ["position", Vector2(50, 300)], ["scope", ""], ["block_format", "On Process"], ["statement", "func _process(delta):"], ["defaults", {}], ["param_input_strings", {}], ["signal_name", ""]] -[sub_resource type="Resource" id="Resource_57n2n"] +[sub_resource type="Resource" id="Resource_s8vl4"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_m3ow7") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_4a0ls")]] +name = &"process_block" +position = Vector2(50, 300) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_enqe8")]] +serialized_block = SubResource("Resource_3wgnl") -[sub_resource type="Resource" id="Resource_cosx1"] +[sub_resource type="Resource" id="Resource_y05sx"] script = ExtResource("6_ppdc3") -array = Array[ExtResource("4_qtggh")]([SubResource("Resource_bfsko"), SubResource("Resource_57n2n")]) +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_hrubs"), SubResource("Resource_s8vl4")]) -[sub_resource type="Resource" id="Resource_krmii"] +[sub_resource type="Resource" id="Resource_ysbi4"] script = ExtResource("7_uuuue") script_inherits = "SimpleCharacter" -block_trees = SubResource("Resource_cosx1") +block_trees = SubResource("Resource_y05sx") variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) generated_script = "extends SimpleCharacter @@ -195,10 +211,10 @@ func _process(delta): " version = 0 -[sub_resource type="Resource" id="Resource_o1lqr"] +[sub_resource type="Resource" id="Resource_rf047"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "load_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Load file {file_path: STRING} as sound {name: STRING}"], ["statement", " +serialized_props = [["block_name", &"load_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Load file {file_path: STRING} as sound {name: STRING}"], ["statement", " var __sound = AudioStreamPlayer.new() __sound.name = {name} __sound.set_stream(load({file_path})) @@ -208,15 +224,17 @@ add_child(__sound) "name": "score_sound" }]] -[sub_resource type="Resource" id="Resource_mipb3"] +[sub_resource type="Resource" id="Resource_d34ke"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_o1lqr") +name = &"load_sound" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_rf047") -[sub_resource type="Resource" id="Resource_648ge"] +[sub_resource type="Resource" id="Resource_md4i5"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "load_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Load file {file_path: STRING} as sound {name: STRING}"], ["statement", " +serialized_props = [["block_name", &"load_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Load file {file_path: STRING} as sound {name: STRING}"], ["statement", " var __sound = AudioStreamPlayer.new() __sound.name = {name} __sound.set_stream(load({file_path})) @@ -226,15 +244,17 @@ add_child(__sound) "name": "wall_hit" }]] -[sub_resource type="Resource" id="Resource_mvbi7"] +[sub_resource type="Resource" id="Resource_roxh4"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_648ge") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_mipb3")]] +name = &"load_sound" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_d34ke")]] +serialized_block = SubResource("Resource_md4i5") -[sub_resource type="Resource" id="Resource_i4exi"] +[sub_resource type="Resource" id="Resource_4luvu"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "load_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Load file {file_path: STRING} as sound {name: STRING}"], ["statement", " +serialized_props = [["block_name", &"load_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Load file {file_path: STRING} as sound {name: STRING}"], ["statement", " var __sound = AudioStreamPlayer.new() __sound.name = {name} __sound.set_stream(load({file_path})) @@ -244,64 +264,144 @@ add_child(__sound) "name": "paddle_hit" }]] -[sub_resource type="Resource" id="Resource_6dpro"] +[sub_resource type="Resource" id="Resource_gywyt"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_i4exi") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_mvbi7")]] +name = &"load_sound" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_roxh4")]] +serialized_block = SubResource("Resource_4luvu") -[sub_resource type="Resource" id="Resource_lds2e"] +[sub_resource type="Resource" id="Resource_b0aen"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "ready_block"], ["label", "EntryBlock"], ["color", Color(0.92549, 0.231373, 0.34902, 1)], ["block_type", 1], ["position", Vector2(-125, 0)], ["scope", ""], ["block_format", "On Ready"], ["statement", "func _ready():"], ["defaults", {}], ["param_input_strings", {}], ["signal_name", ""]] +serialized_props = [["color", Color(0.92549, 0.231373, 0.34902, 1)], ["scope", ""], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_omh7u"] +[sub_resource type="Resource" id="Resource_1h6wi"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_lds2e") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_6dpro")]] +name = &"ready_block" +position = Vector2(54, 47) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_gywyt")]] +serialized_block = SubResource("Resource_b0aen") -[sub_resource type="Resource" id="Resource_2b0uo"] +[sub_resource type="Resource" id="Resource_05cdj"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " +serialized_props = [["block_name", &"viewport_center"], ["label", "Param"], ["color", Color(0.0117647, 0.666667, 0.454902, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Viewport Center"], ["statement", "(func (): var transform: Transform2D = get_viewport_transform(); var scale: Vector2 = transform.get_scale(); return -transform.origin / scale + get_viewport_rect().size / scale / 2).call()"], ["defaults", {}], ["variant_type", 5], ["param_input_strings", {}]] + +[sub_resource type="Resource" id="Resource_kt3qw"] +script = ExtResource("4_qtggh") +name = &"viewport_center" +position = Vector2(0, 0) +path_child_pairs = [] +serialized_block = SubResource("Resource_05cdj") + +[sub_resource type="Resource" id="Resource_uob83"] +script = ExtResource("5_wr38c") +block_class = &"StatementBlock" +serialized_props = [["block_name", &"play_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Play the sound {name: STRING} with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"], ["statement", " +var __sound_node = get_node({name}) +__sound_node.volume_db = {db} +__sound_node.pitch_scale = {pitch} +__sound_node.play() +"], ["defaults", { +"db": "0.0", +"pitch": "1.0" +}], ["param_input_strings", { +"db": "0.0", +"name": "score_sound", +"pitch": "1.0" +}]] + +[sub_resource type="Resource" id="Resource_oawyp"] +script = ExtResource("4_qtggh") +name = &"play_sound" +position = Vector2(0, 0) +path_child_pairs = [] +serialized_block = SubResource("Resource_uob83") + +[sub_resource type="Resource" id="Resource_5x1be"] +script = ExtResource("5_wr38c") +block_class = &"StatementBlock" +serialized_props = [["block_name", &"rigidbody2d_physics_position"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.396078, 0.517647, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set Physics Position {position: VECTOR2}"], ["statement", " +PhysicsServer2D.body_set_state( + get_rid(), + PhysicsServer2D.BODY_STATE_TRANSFORM, + Transform2D.IDENTITY.translated({position}) +) +"], ["defaults", {}], ["param_input_strings", { +"position": "," +}]] + +[sub_resource type="Resource" id="Resource_ftveg"] +script = ExtResource("4_qtggh") +name = &"rigidbody2d_physics_position" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_kt3qw")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_oawyp")]] +serialized_block = SubResource("Resource_5x1be") + +[sub_resource type="Resource" id="Resource_sp3a4"] +script = ExtResource("5_wr38c") +block_class = &"EntryBlock" +serialized_props = [["block_name", &"define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(50, 275)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { +"method_name": "reset" +}], ["signal_name", ""]] + +[sub_resource type="Resource" id="Resource_gmlt0"] +script = ExtResource("4_qtggh") +name = &"define_method" +position = Vector2(50, 275) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_ftveg")]] +serialized_block = SubResource("Resource_sp3a4") + +[sub_resource type="Resource" id="Resource_r1gqk"] +script = ExtResource("5_wr38c") +block_class = &"ParameterBlock" +serialized_props = [["block_name", &"parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_4mv67"] +[sub_resource type="Resource" id="Resource_gj1nu"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_2b0uo") +name = &"parameter_block" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_r1gqk") -[sub_resource type="Resource" id="Resource_1bl8g"] +[sub_resource type="Resource" id="Resource_ri33r"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " +serialized_props = [["block_name", &"parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_01vgy"] +[sub_resource type="Resource" id="Resource_7qpii"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_1bl8g") +name = &"parameter_block" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_ri33r") -[sub_resource type="Resource" id="Resource_ffbl6"] +[sub_resource type="Resource" id="Resource_s7b4y"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { +serialized_props = [["block_name", &"is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { "group": "paddles", "node": "" }]] -[sub_resource type="Resource" id="Resource_smrc0"] +[sub_resource type="Resource" id="Resource_xsgv2"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_ffbl6") -path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_01vgy")]] +name = &"is_node_in_group" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_7qpii")]] +serialized_block = SubResource("Resource_s7b4y") -[sub_resource type="Resource" id="Resource_j0dm5"] +[sub_resource type="Resource" id="Resource_bh5jo"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "play_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(20, 0)], ["scope", ""], ["block_format", "Play the sound {name: STRING} with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"], ["statement", " +serialized_props = [["block_name", &"play_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Play the sound {name: STRING} with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"], ["statement", " var __sound_node = get_node({name}) __sound_node.volume_db = {db} __sound_node.pitch_scale = {pitch} @@ -315,41 +415,47 @@ __sound_node.play() "pitch": "1.0" }]] -[sub_resource type="Resource" id="Resource_earoq"] +[sub_resource type="Resource" id="Resource_ic2jq"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_j0dm5") +name = &"play_sound" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_bh5jo") -[sub_resource type="Resource" id="Resource_t0vy6"] +[sub_resource type="Resource" id="Resource_mgvpf"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " +serialized_props = [["block_name", &"parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_e3mj1"] +[sub_resource type="Resource" id="Resource_mbuv7"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_t0vy6") +name = &"parameter_block" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_mgvpf") -[sub_resource type="Resource" id="Resource_xnogu"] +[sub_resource type="Resource" id="Resource_rc730"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { +serialized_props = [["block_name", &"is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { "group": "walls", "node": "" }]] -[sub_resource type="Resource" id="Resource_njg3m"] +[sub_resource type="Resource" id="Resource_fgryt"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_xnogu") -path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_e3mj1")]] +name = &"is_node_in_group" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_mbuv7")]] +serialized_block = SubResource("Resource_rc730") -[sub_resource type="Resource" id="Resource_4eh0w"] +[sub_resource type="Resource" id="Resource_71yrt"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "play_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(20, 0)], ["scope", ""], ["block_format", "Play the sound {name: STRING} with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"], ["statement", " +serialized_props = [["block_name", &"play_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Play the sound {name: STRING} with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"], ["statement", " var __sound_node = get_node({name}) __sound_node.volume_db = {db} __sound_node.pitch_scale = {pitch} @@ -363,118 +469,64 @@ __sound_node.play() "pitch": "1.0" }]] -[sub_resource type="Resource" id="Resource_wijlv"] +[sub_resource type="Resource" id="Resource_f3xwp"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_4eh0w") +name = &"play_sound" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_71yrt") -[sub_resource type="Resource" id="Resource_4sgol"] +[sub_resource type="Resource" id="Resource_wkj8h"] script = ExtResource("5_wr38c") block_class = &"ControlBlock" -serialized_props = [["block_name", "if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ +serialized_props = [["block_name", &"if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ "condition": false }]]] -[sub_resource type="Resource" id="Resource_kknxb"] +[sub_resource type="Resource" id="Resource_qmdbv"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_4sgol") -path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_njg3m")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_wijlv")]] +name = &"if" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_fgryt")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_f3xwp")]] +serialized_block = SubResource("Resource_wkj8h") -[sub_resource type="Resource" id="Resource_1qbgj"] +[sub_resource type="Resource" id="Resource_dwd2k"] script = ExtResource("5_wr38c") block_class = &"ControlBlock" -serialized_props = [["block_name", "if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ +serialized_props = [["block_name", &"if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ "condition": false }]]] -[sub_resource type="Resource" id="Resource_rop2b"] +[sub_resource type="Resource" id="Resource_rs6a0"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_1qbgj") -path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_smrc0")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_earoq")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_kknxb")]] +name = &"if" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_xsgv2")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_ic2jq")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_qmdbv")]] +serialized_block = SubResource("Resource_dwd2k") -[sub_resource type="Resource" id="Resource_kxhfs"] +[sub_resource type="Resource" id="Resource_7mdg3"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "rigidbody2d_on_entered"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(-125, 225)], ["scope", ""], ["block_format", "On [body: NODE_PATH] entered"], ["statement", " +serialized_props = [["block_name", &"rigidbody2d_on_entered"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(50, 475)], ["scope", ""], ["block_format", "On [body: NODE_PATH] entered"], ["statement", " func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() "], ["defaults", {}], ["param_input_strings", {}], ["signal_name", "body_entered"]] -[sub_resource type="Resource" id="Resource_i5kuh"] -script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_kxhfs") -path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterOutput0/SnapPoint"), SubResource("Resource_4mv67")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_rop2b")]] - -[sub_resource type="Resource" id="Resource_c2usj"] -script = ExtResource("5_wr38c") -block_class = &"ParameterBlock" -serialized_props = [["block_name", "viewport_center"], ["label", "Param"], ["color", Color(0.0117647, 0.666667, 0.454902, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Viewport Center"], ["statement", "(func (): var transform: Transform2D = get_viewport_transform(); var scale: Vector2 = transform.get_scale(); return -transform.origin / scale + get_viewport_rect().size / scale / 2).call()"], ["defaults", {}], ["variant_type", 5], ["param_input_strings", {}]] - -[sub_resource type="Resource" id="Resource_7dr6f"] -script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_c2usj") -path_child_pairs = [] - -[sub_resource type="Resource" id="Resource_yk1aj"] -script = ExtResource("5_wr38c") -block_class = &"StatementBlock" -serialized_props = [["block_name", "play_sound"], ["label", "StatementBlock"], ["color", Color(0.890196, 0.0588235, 0.752941, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Play the sound {name: STRING} with Volume dB {db: FLOAT} and Pitch Scale {pitch: FLOAT}"], ["statement", " -var __sound_node = get_node({name}) -__sound_node.volume_db = {db} -__sound_node.pitch_scale = {pitch} -__sound_node.play() -"], ["defaults", { -"db": "0.0", -"pitch": "1.0" -}], ["param_input_strings", { -"db": "0.0", -"name": "score_sound", -"pitch": "1.0" -}]] - -[sub_resource type="Resource" id="Resource_rjl7j"] -script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_yk1aj") -path_child_pairs = [] - -[sub_resource type="Resource" id="Resource_18v3b"] -script = ExtResource("5_wr38c") -block_class = &"StatementBlock" -serialized_props = [["block_name", "rigidbody2d_physics_position"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.396078, 0.517647, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set Physics Position {position: VECTOR2}"], ["statement", " -PhysicsServer2D.body_set_state( - get_rid(), - PhysicsServer2D.BODY_STATE_TRANSFORM, - Transform2D.IDENTITY.translated({position}) -) -"], ["defaults", {}], ["param_input_strings", { -"position": "," -}]] - -[sub_resource type="Resource" id="Resource_ctlxh"] +[sub_resource type="Resource" id="Resource_tyrtu"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_18v3b") -path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_7dr6f")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_rjl7j")]] +name = &"rigidbody2d_on_entered" +position = Vector2(50, 475) +path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterOutput0/SnapPoint"), SubResource("Resource_gj1nu")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_rs6a0")]] +serialized_block = SubResource("Resource_7mdg3") -[sub_resource type="Resource" id="Resource_wpq1k"] -script = ExtResource("5_wr38c") -block_class = &"EntryBlock" -serialized_props = [["block_name", "define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(-125, 650)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { -"method_name": "reset" -}], ["signal_name", ""]] - -[sub_resource type="Resource" id="Resource_aav67"] -script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_wpq1k") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_ctlxh")]] - -[sub_resource type="Resource" id="Resource_rccbr"] +[sub_resource type="Resource" id="Resource_t48yv"] script = ExtResource("6_ppdc3") -array = Array[ExtResource("4_qtggh")]([SubResource("Resource_omh7u"), SubResource("Resource_i5kuh"), SubResource("Resource_aav67")]) +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_1h6wi"), SubResource("Resource_gmlt0"), SubResource("Resource_tyrtu")]) -[sub_resource type="Resource" id="Resource_181ih"] +[sub_resource type="Resource" id="Resource_6m2mk"] script = ExtResource("7_uuuue") script_inherits = "RigidBody2D" -block_trees = SubResource("Resource_rccbr") +block_trees = SubResource("Resource_t48yv") variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) generated_script = "extends RigidBody2D @@ -493,6 +545,17 @@ func _ready(): __sound_3.set_stream(load('res://addons/block_code/examples/pong_game/assets/score.ogg')) add_child(__sound_3) +func reset(): + PhysicsServer2D.body_set_state( + get_rid(), + PhysicsServer2D.BODY_STATE_TRANSFORM, + Transform2D.IDENTITY.translated((func (): var transform: Transform2D = get_viewport_transform(); var scale: Vector2 = transform.get_scale(); return -transform.origin / scale + get_viewport_rect().size / scale / 2).call()) + ) + var __sound_node_1 = get_node('score_sound') + __sound_node_1.volume_db = 0.0 + __sound_node_1.pitch_scale = 1.0 + __sound_node_1.play() + func _on_body_entered(_body: Node): var body: NodePath = _body.get_path() @@ -508,120 +571,123 @@ func _on_body_entered(_body: Node): __sound_node_2.pitch_scale = 1.0 __sound_node_2.play() -func reset(): - PhysicsServer2D.body_set_state( - get_rid(), - PhysicsServer2D.BODY_STATE_TRANSFORM, - Transform2D.IDENTITY.translated((func (): var transform: Transform2D = get_viewport_transform(); var scale: Vector2 = transform.get_scale(); return -transform.origin / scale + get_viewport_rect().size / scale / 2).call()) - ) - var __sound_node_1 = get_node('score_sound') - __sound_node_1.volume_db = 0.0 - __sound_node_1.pitch_scale = 1.0 - __sound_node_1.play() - func _init(): body_entered.connect(_on_body_entered) " version = 0 -[sub_resource type="Resource" id="Resource_0k8hj"] +[sub_resource type="Resource" id="Resource_itmch"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " +serialized_props = [["block_name", &"parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " func _on_body_entered(_body: Node2D): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_rig6c"] +[sub_resource type="Resource" id="Resource_3wodo"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_0k8hj") +name = &"parameter_block" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_itmch") -[sub_resource type="Resource" id="Resource_t7w1d"] +[sub_resource type="Resource" id="Resource_wo02o"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " +serialized_props = [["block_name", &"parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " func _on_body_entered(_body: Node2D): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_ba0bv"] +[sub_resource type="Resource" id="Resource_dcwek"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_t7w1d") +name = &"parameter_block" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_wo02o") -[sub_resource type="Resource" id="Resource_jtjm4"] +[sub_resource type="Resource" id="Resource_ma3m2"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { +serialized_props = [["block_name", &"is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { "group": "balls", "node": "" }]] -[sub_resource type="Resource" id="Resource_62spx"] +[sub_resource type="Resource" id="Resource_bny5u"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_jtjm4") -path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_ba0bv")]] +name = &"is_node_in_group" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_dcwek")]] +serialized_block = SubResource("Resource_ma3m2") -[sub_resource type="Resource" id="Resource_e25gs"] +[sub_resource type="Resource" id="Resource_dkm1h"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "call_group_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in group {group: STRING}"], ["statement", "get_tree().call_group({group}, {method_name})"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"call_group_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in group {group: STRING}"], ["statement", "get_tree().call_group({group}, {method_name})"], ["defaults", {}], ["param_input_strings", { "group": "balls", "method_name": "reset" }]] -[sub_resource type="Resource" id="Resource_k1bnq"] +[sub_resource type="Resource" id="Resource_57tvt"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_e25gs") +name = &"call_group_method" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_dkm1h") -[sub_resource type="Resource" id="Resource_3574g"] +[sub_resource type="Resource" id="Resource_lm5iy"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "call_group_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(20, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in group {group: STRING}"], ["statement", "get_tree().call_group({group}, {method_name})"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"call_group_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in group {group: STRING}"], ["statement", "get_tree().call_group({group}, {method_name})"], ["defaults", {}], ["param_input_strings", { "group": "scoring", "method_name": "goal_left" }]] -[sub_resource type="Resource" id="Resource_sgg3i"] +[sub_resource type="Resource" id="Resource_26pqe"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_3574g") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_k1bnq")]] +name = &"call_group_method" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_57tvt")]] +serialized_block = SubResource("Resource_lm5iy") -[sub_resource type="Resource" id="Resource_o07o5"] +[sub_resource type="Resource" id="Resource_yd7xk"] script = ExtResource("5_wr38c") block_class = &"ControlBlock" -serialized_props = [["block_name", "if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ +serialized_props = [["block_name", &"if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ "condition": false }]]] -[sub_resource type="Resource" id="Resource_ja7i6"] +[sub_resource type="Resource" id="Resource_wva5q"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_o07o5") -path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_62spx")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_sgg3i")]] +name = &"if" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_bny5u")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_26pqe")]] +serialized_block = SubResource("Resource_yd7xk") -[sub_resource type="Resource" id="Resource_8e6vl"] +[sub_resource type="Resource" id="Resource_fufky"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "area2d_on_entered"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(-125, -150)], ["scope", ""], ["block_format", "On [body: NODE_PATH] entered"], ["statement", " +serialized_props = [["block_name", &"area2d_on_entered"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(100, 50)], ["scope", ""], ["block_format", "On [body: NODE_PATH] entered"], ["statement", " func _on_body_entered(_body: Node2D): var body: NodePath = _body.get_path() "], ["defaults", {}], ["param_input_strings", {}], ["signal_name", "body_entered"]] -[sub_resource type="Resource" id="Resource_dymgt"] +[sub_resource type="Resource" id="Resource_fkj3e"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_8e6vl") -path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterOutput0/SnapPoint"), SubResource("Resource_rig6c")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_ja7i6")]] +name = &"area2d_on_entered" +position = Vector2(100, 50) +path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterOutput0/SnapPoint"), SubResource("Resource_3wodo")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_wva5q")]] +serialized_block = SubResource("Resource_fufky") -[sub_resource type="Resource" id="Resource_qatrc"] +[sub_resource type="Resource" id="Resource_v6too"] script = ExtResource("6_ppdc3") -array = Array[ExtResource("4_qtggh")]([SubResource("Resource_dymgt")]) +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_fkj3e")]) -[sub_resource type="Resource" id="Resource_1yrql"] +[sub_resource type="Resource" id="Resource_4xylj"] script = ExtResource("7_uuuue") script_inherits = "Area2D" -block_trees = SubResource("Resource_qatrc") +block_trees = SubResource("Resource_v6too") variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) generated_script = "extends Area2D @@ -639,104 +705,118 @@ func _init(): " version = 0 -[sub_resource type="Resource" id="Resource_mvpfc"] +[sub_resource type="Resource" id="Resource_8h48s"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " +serialized_props = [["block_name", &"parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " func _on_body_entered(_body: Node2D): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_v2e4o"] +[sub_resource type="Resource" id="Resource_0x61c"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_mvpfc") +name = &"parameter_block" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_8h48s") -[sub_resource type="Resource" id="Resource_lt2nr"] +[sub_resource type="Resource" id="Resource_n8f73"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " +serialized_props = [["block_name", &"parameter_block"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", " func _on_body_entered(_body: Node2D): var body: NodePath = _body.get_path() "], ["block_format", "body"], ["statement", "body"], ["defaults", {}], ["variant_type", 22], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_6417q"] +[sub_resource type="Resource" id="Resource_tnwiy"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_lt2nr") +name = &"parameter_block" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_n8f73") -[sub_resource type="Resource" id="Resource_ppyp4"] +[sub_resource type="Resource" id="Resource_lurjo"] script = ExtResource("5_wr38c") block_class = &"ParameterBlock" -serialized_props = [["block_name", "is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { +serialized_props = [["block_name", &"is_node_in_group"], ["label", "Param"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 3], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Is {node: NODE_PATH} in group {group: STRING}"], ["statement", "get_node({node}).is_in_group({group})"], ["defaults", {}], ["variant_type", 1], ["param_input_strings", { "group": "balls", "node": "" }]] -[sub_resource type="Resource" id="Resource_i1hbe"] +[sub_resource type="Resource" id="Resource_j6idn"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_ppyp4") -path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_6417q")]] +name = &"is_node_in_group" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("MarginContainer/HBoxContainer/ParameterInput0/SnapPoint"), SubResource("Resource_tnwiy")]] +serialized_block = SubResource("Resource_lurjo") -[sub_resource type="Resource" id="Resource_og2lu"] +[sub_resource type="Resource" id="Resource_y2wc6"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "call_group_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in group {group: STRING}"], ["statement", "get_tree().call_group({group}, {method_name})"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"call_group_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in group {group: STRING}"], ["statement", "get_tree().call_group({group}, {method_name})"], ["defaults", {}], ["param_input_strings", { "group": "balls", "method_name": "reset" }]] -[sub_resource type="Resource" id="Resource_ox4cg"] +[sub_resource type="Resource" id="Resource_krykp"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_og2lu") +name = &"call_group_method" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_y2wc6") -[sub_resource type="Resource" id="Resource_fqtoj"] +[sub_resource type="Resource" id="Resource_daagb"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "call_group_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(20, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in group {group: STRING}"], ["statement", "get_tree().call_group({group}, {method_name})"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"call_group_method"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Call method {method_name: STRING} in group {group: STRING}"], ["statement", "get_tree().call_group({group}, {method_name})"], ["defaults", {}], ["param_input_strings", { "group": "scoring", "method_name": "goal_right" }]] -[sub_resource type="Resource" id="Resource_16dgc"] +[sub_resource type="Resource" id="Resource_klxbs"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_fqtoj") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_ox4cg")]] +name = &"call_group_method" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_krykp")]] +serialized_block = SubResource("Resource_daagb") -[sub_resource type="Resource" id="Resource_4gpkr"] +[sub_resource type="Resource" id="Resource_twkoi"] script = ExtResource("5_wr38c") block_class = &"ControlBlock" -serialized_props = [["block_name", "if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ +serialized_props = [["block_name", &"if"], ["label", "Control Block"], ["color", Color(0.270588, 0.666667, 0.94902, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_formats", ["if {condition: BOOL}"]], ["statements", ["if {condition}:"]], ["defaults", {}], ["param_input_strings_array", [{ "condition": false }]]] -[sub_resource type="Resource" id="Resource_cujjt"] +[sub_resource type="Resource" id="Resource_1a3km"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_4gpkr") -path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_i1hbe")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_16dgc")]] +name = &"if" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/MarginContainer/Rows/Row0/RowHBoxContainer/RowHBox/ParameterInput0/SnapPoint"), SubResource("Resource_j6idn")], [NodePath("VBoxContainer/MarginContainer/Rows/SnapContainer0/SnapPoint"), SubResource("Resource_klxbs")]] +serialized_block = SubResource("Resource_twkoi") -[sub_resource type="Resource" id="Resource_nkcib"] +[sub_resource type="Resource" id="Resource_c4had"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "area2d_on_entered"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(-150, -75)], ["scope", ""], ["block_format", "On [body: NODE_PATH] entered"], ["statement", " +serialized_props = [["block_name", &"area2d_on_entered"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(75, 50)], ["scope", ""], ["block_format", "On [body: NODE_PATH] entered"], ["statement", " func _on_body_entered(_body: Node2D): var body: NodePath = _body.get_path() "], ["defaults", {}], ["param_input_strings", {}], ["signal_name", "body_entered"]] -[sub_resource type="Resource" id="Resource_kibpx"] +[sub_resource type="Resource" id="Resource_qtw4n"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_nkcib") -path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterOutput0/SnapPoint"), SubResource("Resource_v2e4o")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_cujjt")]] +name = &"area2d_on_entered" +position = Vector2(75, 50) +path_child_pairs = [[NodePath("VBoxContainer/TopMarginContainer/MarginContainer/HBoxContainer/ParameterOutput0/SnapPoint"), SubResource("Resource_0x61c")], [NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_1a3km")]] +serialized_block = SubResource("Resource_c4had") -[sub_resource type="Resource" id="Resource_rdqcq"] +[sub_resource type="Resource" id="Resource_14gac"] script = ExtResource("6_ppdc3") -array = Array[ExtResource("4_qtggh")]([SubResource("Resource_kibpx")]) +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_qtw4n")]) -[sub_resource type="Resource" id="Resource_nf08t"] +[sub_resource type="Resource" id="Resource_xoc8a"] script = ExtResource("7_uuuue") script_inherits = "Area2D" -block_trees = SubResource("Resource_rdqcq") +block_trees = SubResource("Resource_14gac") variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) generated_script = "extends Area2D @@ -754,108 +834,124 @@ func _init(): " version = 0 -[sub_resource type="Resource" id="Resource_esgb0"] +[sub_resource type="Resource" id="Resource_tqdqf"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "add_to_group"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Add to group {group: STRING}"], ["statement", "add_to_group({group})"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"add_to_group"], ["label", "StatementBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Add to group {group: STRING}"], ["statement", "add_to_group({group})"], ["defaults", {}], ["param_input_strings", { "group": "scoring" }]] -[sub_resource type="Resource" id="Resource_2cvgo"] +[sub_resource type="Resource" id="Resource_uxpim"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_esgb0") +name = &"add_to_group" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_tqdqf") -[sub_resource type="Resource" id="Resource_yt2jg"] +[sub_resource type="Resource" id="Resource_yuj6e"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "simplescoring_set_score"], ["label", "StatementBlock"], ["color", Color(0.811765, 0.415686, 0.529412, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set player 2 score to {score: INT}"], ["statement", "score_right = {score}"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"simplescoring_set_score"], ["label", "StatementBlock"], ["color", Color(0.811765, 0.415686, 0.529412, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set player 2 score to {score: INT}"], ["statement", "score_right = {score}"], ["defaults", {}], ["param_input_strings", { "score": "0" }]] -[sub_resource type="Resource" id="Resource_qxyq6"] +[sub_resource type="Resource" id="Resource_oar78"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_yt2jg") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_2cvgo")]] +name = &"simplescoring_set_score" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_uxpim")]] +serialized_block = SubResource("Resource_yuj6e") -[sub_resource type="Resource" id="Resource_dptse"] +[sub_resource type="Resource" id="Resource_gkoq3"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "simplescoring_set_score"], ["label", "StatementBlock"], ["color", Color(0.811765, 0.415686, 0.529412, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set player 1 score to {score: INT}"], ["statement", "score_left = {score}"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"simplescoring_set_score"], ["label", "StatementBlock"], ["color", Color(0.811765, 0.415686, 0.529412, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Set player 1 score to {score: INT}"], ["statement", "score_left = {score}"], ["defaults", {}], ["param_input_strings", { "score": "0" }]] -[sub_resource type="Resource" id="Resource_6g2pn"] +[sub_resource type="Resource" id="Resource_8xxm3"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_dptse") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_qxyq6")]] +name = &"simplescoring_set_score" +position = Vector2(0, 0) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_oar78")]] +serialized_block = SubResource("Resource_gkoq3") -[sub_resource type="Resource" id="Resource_u7gx0"] +[sub_resource type="Resource" id="Resource_g3mty"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "ready_block"], ["label", "EntryBlock"], ["color", Color(0.92549, 0.231373, 0.34902, 1)], ["block_type", 1], ["position", Vector2(-350, -275)], ["scope", ""], ["block_format", "On Ready"], ["statement", "func _ready():"], ["defaults", {}], ["param_input_strings", {}], ["signal_name", ""]] +serialized_props = [["color", Color(0.92549, 0.231373, 0.34902, 1)], ["scope", ""], ["param_input_strings", {}]] -[sub_resource type="Resource" id="Resource_jlgm4"] +[sub_resource type="Resource" id="Resource_njwj4"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_u7gx0") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_6g2pn")]] +name = &"ready_block" +position = Vector2(54, 47) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_8xxm3")]] +serialized_block = SubResource("Resource_g3mty") -[sub_resource type="Resource" id="Resource_ipq2j"] +[sub_resource type="Resource" id="Resource_3j7i4"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "simplescoring_change_score"], ["label", "StatementBlock"], ["color", Color(0.811765, 0.415686, 0.529412, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Change player 1 score by {score: INT}"], ["statement", "score_left += {score}"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"simplescoring_change_score"], ["label", "StatementBlock"], ["color", Color(0.811765, 0.415686, 0.529412, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Change player 1 score by {score: INT}"], ["statement", "score_left += {score}"], ["defaults", {}], ["param_input_strings", { "score": "1" }]] -[sub_resource type="Resource" id="Resource_imfrt"] +[sub_resource type="Resource" id="Resource_ntjp0"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_ipq2j") +name = &"simplescoring_change_score" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_3j7i4") -[sub_resource type="Resource" id="Resource_uu4ng"] +[sub_resource type="Resource" id="Resource_2e0ed"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(-350, -50)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(50, 300)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { "method_name": "goal_right" }], ["signal_name", ""]] -[sub_resource type="Resource" id="Resource_ed551"] +[sub_resource type="Resource" id="Resource_t8g7r"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_uu4ng") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_imfrt")]] +name = &"define_method" +position = Vector2(50, 300) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_ntjp0")]] +serialized_block = SubResource("Resource_2e0ed") -[sub_resource type="Resource" id="Resource_5qjag"] +[sub_resource type="Resource" id="Resource_cxj82"] script = ExtResource("5_wr38c") block_class = &"StatementBlock" -serialized_props = [["block_name", "simplescoring_change_score"], ["label", "StatementBlock"], ["color", Color(0.811765, 0.415686, 0.529412, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Change player 2 score by {score: INT}"], ["statement", "score_right += {score}"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"simplescoring_change_score"], ["label", "StatementBlock"], ["color", Color(0.811765, 0.415686, 0.529412, 1)], ["block_type", 2], ["position", Vector2(0, 0)], ["scope", ""], ["block_format", "Change player 2 score by {score: INT}"], ["statement", "score_right += {score}"], ["defaults", {}], ["param_input_strings", { "score": "1" }]] -[sub_resource type="Resource" id="Resource_fyy20"] +[sub_resource type="Resource" id="Resource_c17ry"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_5qjag") +name = &"simplescoring_change_score" +position = Vector2(0, 0) path_child_pairs = [] +serialized_block = SubResource("Resource_cxj82") -[sub_resource type="Resource" id="Resource_yxdgk"] +[sub_resource type="Resource" id="Resource_udc68"] script = ExtResource("5_wr38c") block_class = &"EntryBlock" -serialized_props = [["block_name", "define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(-350, 75)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { +serialized_props = [["block_name", &"define_method"], ["label", "EntryBlock"], ["color", Color(0.294118, 0.482353, 0.92549, 1)], ["block_type", 1], ["position", Vector2(50, 450)], ["scope", ""], ["block_format", "Define method {method_name: NIL}"], ["statement", "func {method_name}():"], ["defaults", {}], ["param_input_strings", { "method_name": "goal_left" }], ["signal_name", ""]] -[sub_resource type="Resource" id="Resource_4v0rp"] +[sub_resource type="Resource" id="Resource_v2aur"] script = ExtResource("4_qtggh") -serialized_block = SubResource("Resource_yxdgk") -path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_fyy20")]] +name = &"define_method" +position = Vector2(50, 450) +path_child_pairs = [[NodePath("VBoxContainer/SnapPoint"), SubResource("Resource_c17ry")]] +serialized_block = SubResource("Resource_udc68") -[sub_resource type="Resource" id="Resource_g42ud"] +[sub_resource type="Resource" id="Resource_cu24c"] script = ExtResource("6_ppdc3") -array = Array[ExtResource("4_qtggh")]([SubResource("Resource_jlgm4"), SubResource("Resource_ed551"), SubResource("Resource_4v0rp")]) +array = Array[ExtResource("4_qtggh")]([SubResource("Resource_njwj4"), SubResource("Resource_t8g7r"), SubResource("Resource_v2aur")]) -[sub_resource type="Resource" id="Resource_xe6aa"] +[sub_resource type="Resource" id="Resource_q418f"] script = ExtResource("7_uuuue") script_inherits = "SimpleScoring" -block_trees = SubResource("Resource_g42ud") +block_trees = SubResource("Resource_cu24c") variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) generated_script = "extends SimpleScoring @@ -887,7 +983,7 @@ texture = ExtResource("4_ra7bh") [node name="BlockCode" type="Node" parent="PaddleLeft"] script = ExtResource("3_6jaq8") -block_script = SubResource("Resource_dhvli") +block_script = SubResource("Resource_m2svk") [node name="PaddleRight" type="CharacterBody2D" parent="." groups=["paddles"]] modulate = Color(0.509804, 0.360784, 0.972549, 1) @@ -898,7 +994,7 @@ texture = ExtResource("4_ra7bh") [node name="BlockCode" type="Node" parent="PaddleRight"] script = ExtResource("3_6jaq8") -block_script = SubResource("Resource_krmii") +block_script = SubResource("Resource_ysbi4") [node name="Ball" parent="." instance=ExtResource("9_xrqll")] modulate = Color(0.511, 0.362, 0.972, 1) @@ -907,21 +1003,21 @@ gravity_scale = 0.0 [node name="BlockCode" type="Node" parent="Ball"] script = ExtResource("3_6jaq8") -block_script = SubResource("Resource_181ih") +block_script = SubResource("Resource_6m2mk") [node name="GoalAreaLeft" parent="." groups=["goal", "goal_left"] instance=ExtResource("12_nqmxu")] position = Vector2(-64, 544) [node name="BlockCode" type="Node" parent="GoalAreaLeft"] script = ExtResource("3_6jaq8") -block_script = SubResource("Resource_1yrql") +block_script = SubResource("Resource_4xylj") [node name="GoalAreaRight" parent="." groups=["goal", "goal_right"] instance=ExtResource("12_nqmxu")] position = Vector2(1984, 544) [node name="BlockCode" type="Node" parent="GoalAreaRight"] script = ExtResource("3_6jaq8") -block_script = SubResource("Resource_nf08t") +block_script = SubResource("Resource_xoc8a") [node name="SimpleScoring" type="CanvasLayer" parent="." groups=["hud"]] follow_viewport_enabled = true @@ -929,7 +1025,7 @@ script = ExtResource("13_tg3yk") [node name="BlockCode" type="Node" parent="SimpleScoring"] script = ExtResource("3_6jaq8") -block_script = SubResource("Resource_xe6aa") +block_script = SubResource("Resource_q418f") [node name="Camera2D" type="Camera2D" parent="."] position = Vector2(960, 540) diff --git a/addons/block_code/ui/block_canvas/block_canvas.gd b/addons/block_code/ui/block_canvas/block_canvas.gd index 867afeed..d34c4139 100644 --- a/addons/block_code/ui/block_canvas/block_canvas.gd +++ b/addons/block_code/ui/block_canvas/block_canvas.gd @@ -161,10 +161,16 @@ func clear_canvas(): func load_tree(parent: Node, node: SerializedBlockTreeNode): - var _block_scene_path = _block_scenes_by_class[node.serialized_block.block_class] - var scene: Block = load(_block_scene_path).instantiate() + var scene: Block = Util.instantiate_block(node.name) + + # TODO: Remove once the data/UI decouple is done. + if scene == null: + var _block_scene_path = _block_scenes_by_class[node.serialized_block.block_class] + scene = load(_block_scene_path).instantiate() for prop_pair in node.serialized_block.serialized_props: scene.set(prop_pair[0], prop_pair[1]) + + scene.position = node.position scene.resource = node parent.add_child(scene) diff --git a/addons/block_code/ui/block_canvas/serialized_block_tree_node.gd b/addons/block_code/ui/block_canvas/serialized_block_tree_node.gd index b524715c..9f4b95fd 100644 --- a/addons/block_code/ui/block_canvas/serialized_block_tree_node.gd +++ b/addons/block_code/ui/block_canvas/serialized_block_tree_node.gd @@ -1,10 +1,16 @@ class_name SerializedBlockTreeNode extends Resource -@export var serialized_block: SerializedBlock +@export var name: StringName +@export var position: Vector2 @export var path_child_pairs: Array +# TODO: Remove once the data/UI decouple is done. +@export var serialized_block: SerializedBlock + -func _init(p_serialized_block: SerializedBlock = null, p_path_child_pairs: Array = []): +func _init(p_name: StringName, p_position: Vector2 = Vector2.ZERO, p_serialized_block: SerializedBlock = null, p_path_child_pairs: Array = []): + name = p_name + position = p_position serialized_block = p_serialized_block path_child_pairs = p_path_child_pairs diff --git a/addons/block_code/ui/blocks/block/block.gd b/addons/block_code/ui/blocks/block/block.gd index 5cb37baf..6818b76d 100644 --- a/addons/block_code/ui/blocks/block/block.gd +++ b/addons/block_code/ui/blocks/block/block.gd @@ -2,6 +2,7 @@ class_name Block extends MarginContainer +const BlocksCatalog = preload("res://addons/block_code/blocks_catalog.gd") const InstructionTree = preload("res://addons/block_code/instruction_tree/instruction_tree.gd") const Types = preload("res://addons/block_code/types/types.gd") @@ -9,7 +10,7 @@ signal drag_started(block: Block) signal modified ## Name of the block to be referenced by others in search -@export var block_name: String = "" +@export var block_name: StringName ## Label of block (optionally used to draw block labels) @export var label: String = "" @@ -83,10 +84,15 @@ func get_instruction_node() -> InstructionTree.TreeNode: func update_resources(undo_redo: EditorUndoRedoManager): if resource == null: var serialized_block = SerializedBlock.new(get_block_class(), get_serialized_props()) - resource = SerializedBlockTreeNode.new(serialized_block) + resource = SerializedBlockTreeNode.new(block_name, position, serialized_block) return + if resource.position != position: + undo_redo.add_undo_property(resource, "position", resource.position) + undo_redo.add_do_property(resource, "position", position) + var serialized_props = get_serialized_props() + if serialized_props != resource.serialized_block.serialized_props: undo_redo.add_undo_property(resource.serialized_block, "serialized_props", resource.serialized_block.serialized_props) undo_redo.add_do_property(resource.serialized_block, "serialized_props", serialized_props) @@ -94,7 +100,13 @@ func update_resources(undo_redo: EditorUndoRedoManager): # Override this method to add more serialized properties func get_serialized_props() -> Array: - return serialize_props(["block_name", "label", "color", "block_type", "position", "scope"]) + if not BlocksCatalog.has_block(block_name): + return serialize_props(["block_name", "label", "color", "block_type", "position", "scope"]) + + # TODO: Remove remaining serialization: + # - Derive color from category. + # - Handle scope in a different way? + return serialize_props(["color", "scope"]) func _to_string(): diff --git a/addons/block_code/ui/blocks/control_block/control_block.tscn b/addons/block_code/ui/blocks/control_block/control_block.tscn index a482e11f..6e77f7d6 100644 --- a/addons/block_code/ui/blocks/control_block/control_block.tscn +++ b/addons/block_code/ui/blocks/control_block/control_block.tscn @@ -7,7 +7,7 @@ size_flags_horizontal = 0 mouse_filter = 2 script = ExtResource("1_2hbir") -block_name = "control_block" +block_name = &"control_block" label = "Control Block" color = Color(0.59979, 0.536348, 0.876215, 1) bottom_snap_path = NodePath("VBoxContainer/SnapPoint") diff --git a/addons/block_code/ui/blocks/entry_block/entry_block.gd b/addons/block_code/ui/blocks/entry_block/entry_block.gd index 3b53937b..0659d4bc 100644 --- a/addons/block_code/ui/blocks/entry_block/entry_block.gd +++ b/addons/block_code/ui/blocks/entry_block/entry_block.gd @@ -30,5 +30,6 @@ func get_entry_statement() -> String: func get_serialized_props() -> Array: var props := super() - props.append_array(serialize_props(["signal_name"])) + if not BlocksCatalog.has_block(block_name): + props.append_array(serialize_props(["signal_name"])) return props diff --git a/addons/block_code/ui/blocks/entry_block/entry_block.tscn b/addons/block_code/ui/blocks/entry_block/entry_block.tscn index 6abed53e..49774a00 100644 --- a/addons/block_code/ui/blocks/entry_block/entry_block.tscn +++ b/addons/block_code/ui/blocks/entry_block/entry_block.tscn @@ -6,8 +6,7 @@ [node name="EntryBlock" instance=ExtResource("1_byjbb")] script = ExtResource("2_3ik8h") signal_name = "" -defaults = {} -block_name = "entry_block" +block_name = &"entry_block" label = "EntryBlock" block_type = 1 diff --git a/addons/block_code/ui/blocks/parameter_block/parameter_block.tscn b/addons/block_code/ui/blocks/parameter_block/parameter_block.tscn index 46cc8b65..5700ae20 100644 --- a/addons/block_code/ui/blocks/parameter_block/parameter_block.tscn +++ b/addons/block_code/ui/blocks/parameter_block/parameter_block.tscn @@ -18,9 +18,9 @@ corner_radius_bottom_left = 16 offset_right = 16.0 offset_bottom = 8.0 size_flags_horizontal = 0 +mouse_filter = 2 script = ExtResource("1_0hajy") -defaults = null -block_name = "parameter_block" +block_name = &"parameter_block" label = "Param" block_type = 3 diff --git a/addons/block_code/ui/blocks/statement_block/statement_block.gd b/addons/block_code/ui/blocks/statement_block/statement_block.gd index cea6a6fc..fb920108 100644 --- a/addons/block_code/ui/blocks/statement_block/statement_block.gd +++ b/addons/block_code/ui/blocks/statement_block/statement_block.gd @@ -36,7 +36,8 @@ func _on_drag_drop_area_mouse_down(): func get_serialized_props() -> Array: var props := super() - props.append_array(serialize_props(["block_format", "statement", "defaults"])) + if not BlocksCatalog.has_block(block_name): + props.append_array(serialize_props(["block_format", "statement", "defaults"])) var _param_input_strings: Dictionary = {} for pair in param_name_input_pairs: diff --git a/addons/block_code/ui/blocks/statement_block/statement_block.tscn b/addons/block_code/ui/blocks/statement_block/statement_block.tscn index 96ed6e48..7463bf4f 100644 --- a/addons/block_code/ui/blocks/statement_block/statement_block.tscn +++ b/addons/block_code/ui/blocks/statement_block/statement_block.tscn @@ -9,7 +9,7 @@ size_flags_horizontal = 0 mouse_filter = 2 script = ExtResource("1_6wvlf") -block_name = "statement_block" +block_name = &"statement_block" label = "StatementBlock" bottom_snap_path = NodePath("VBoxContainer/SnapPoint") diff --git a/addons/block_code/ui/bsd_templates/default_blocktrees.tres b/addons/block_code/ui/bsd_templates/default_blocktrees.tres deleted file mode 100644 index fef4c4a1..00000000 --- a/addons/block_code/ui/bsd_templates/default_blocktrees.tres +++ /dev/null @@ -1,29 +0,0 @@ -[gd_resource type="Resource" script_class="SerializedBlockTreeNodeArray" load_steps=8 format=3 uid="uid://djn5nejdsfu2a"] - -[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node.gd" id="1_mfn7y"] -[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block.gd" id="2_qtg7h"] -[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node_array.gd" id="3_jo5dc"] - -[sub_resource type="Resource" id="Resource_lonji"] -script = ExtResource("2_qtg7h") -block_class = &"EntryBlock" -serialized_props = [["block_name", "ready_block"], ["label", "EntryBlock"], ["color", Color(0.980392, 0.34902, 0.337255, 1)], ["block_type", 2], ["position", Vector2(54, 47)], ["block_format", "On Ready"], ["statement", "func _ready():"], ["param_input_strings", {}]] - -[sub_resource type="Resource" id="Resource_uxduk"] -script = ExtResource("1_mfn7y") -serialized_block = SubResource("Resource_lonji") -path_child_pairs = [] - -[sub_resource type="Resource" id="Resource_8uoy7"] -script = ExtResource("2_qtg7h") -block_class = &"EntryBlock" -serialized_props = [["block_name", "process_block"], ["label", "EntryBlock"], ["color", Color(0.980392, 0.34902, 0.337255, 1)], ["block_type", 2], ["position", Vector2(525, 48)], ["block_format", "On Process"], ["statement", "func _process(delta):"], ["param_input_strings", {}]] - -[sub_resource type="Resource" id="Resource_qsjc2"] -script = ExtResource("1_mfn7y") -serialized_block = SubResource("Resource_8uoy7") -path_child_pairs = [] - -[resource] -script = ExtResource("3_jo5dc") -array = Array[ExtResource("1_mfn7y")]([SubResource("Resource_uxduk"), SubResource("Resource_qsjc2")]) diff --git a/addons/block_code/ui/bsd_templates/default_bsd.tres b/addons/block_code/ui/bsd_templates/default_bsd.tres index ebb149e2..5bfa7671 100644 --- a/addons/block_code/ui/bsd_templates/default_bsd.tres +++ b/addons/block_code/ui/bsd_templates/default_bsd.tres @@ -1,10 +1,30 @@ -[gd_resource type="Resource" script_class="BlockScriptData" load_steps=3 format=3 uid="uid://dit7fykhl3h48"] +[gd_resource type="Resource" script_class="BlockScriptData" load_steps=8 format=3 uid="uid://dit7fykhl3h48"] -[ext_resource type="Script" path="res://addons/block_code/block_script_data/block_script_data.gd" id="1_h8ggn"] -[ext_resource type="Resource" uid="uid://djn5nejdsfu2a" path="res://addons/block_code/ui/bsd_templates/default_blocktrees.tres" id="1_y70fv"] +[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node.gd" id="1_barc5"] +[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block.gd" id="2_cgfpx"] +[ext_resource type="Script" path="res://addons/block_code/ui/block_canvas/serialized_block_tree_node_array.gd" id="3_gx4d7"] +[ext_resource type="Script" path="res://addons/block_code/block_script_data/block_script_data.gd" id="4_cqq7x"] + +[sub_resource type="Resource" id="Resource_b0aen"] +script = ExtResource("2_cgfpx") +block_class = &"EntryBlock" +serialized_props = [["color", Color(0.92549, 0.231373, 0.34902, 1)], ["scope", ""], ["param_input_strings", {}]] + +[sub_resource type="Resource" id="Resource_1h6wi"] +script = ExtResource("1_barc5") +name = &"ready_block" +position = Vector2(54, 47) +path_child_pairs = [] +serialized_block = SubResource("Resource_b0aen") + +[sub_resource type="Resource" id="Resource_nkub8"] +script = ExtResource("3_gx4d7") +array = Array[ExtResource("1_barc5")]([SubResource("Resource_1h6wi")]) [resource] -script = ExtResource("1_h8ggn") +script = ExtResource("4_cqq7x") script_inherits = "INHERIT_DEFAULT" -block_trees = ExtResource("1_y70fv") +block_trees = SubResource("Resource_nkub8") +variables = Array[Resource("res://addons/block_code/ui/block_canvas/variable_resource.gd")]([]) generated_script = "extends INHERIT_DEFAULT" +version = 0 diff --git a/addons/block_code/ui/picker/categories/category_factory.gd b/addons/block_code/ui/picker/categories/category_factory.gd index 14d03b7c..848d5301 100644 --- a/addons/block_code/ui/picker/categories/category_factory.gd +++ b/addons/block_code/ui/picker/categories/category_factory.gd @@ -3,6 +3,7 @@ extends Object const BlockCategory = preload("res://addons/block_code/ui/picker/categories/block_category.gd") const Types = preload("res://addons/block_code/types/types.gd") +const Util = preload("res://addons/block_code/ui/util.gd") const BLOCKS: Dictionary = { "control_block": preload("res://addons/block_code/ui/blocks/control_block/control_block.tscn"), @@ -171,12 +172,7 @@ static func get_general_blocks() -> Array[Block]: #region Lifecycle - b = BLOCKS["entry_block"].instantiate() - b.block_name = "ready_block" - b.block_format = "On Ready" - b.statement = "func _ready():" - b.tooltip_text = 'Attached blocks will be executed once when the node is "ready"' - b.category = "Lifecycle" + b = Util.instantiate_block(&"ready_block") block_list.append(b) b = BLOCKS["entry_block"].instantiate() @@ -259,13 +255,7 @@ static func get_general_blocks() -> Array[Block]: #endregion #region Logs - b = BLOCKS["statement_block"].instantiate() - b.block_name = "print" - b.block_format = "print {text: STRING}" - b.statement = "print({text})" - b.defaults = {"text": "Hello"} - b.tooltip_text = "Print the text to output" - b.category = "Log" + b = Util.instantiate_block(&"print") block_list.append(b) #endregion diff --git a/addons/block_code/ui/util.gd b/addons/block_code/ui/util.gd index 46918d2f..53dd91d0 100644 --- a/addons/block_code/ui/util.gd +++ b/addons/block_code/ui/util.gd @@ -1,5 +1,34 @@ extends Object +const BlockDefinition = preload("res://addons/block_code/block_definition.gd") +const BlocksCatalog = preload("res://addons/block_code/blocks_catalog.gd") +const Types = preload("res://addons/block_code/types/types.gd") + +const SCENE_PER_TYPE = { + Types.BlockType.ENTRY: preload("res://addons/block_code/ui/blocks/entry_block/entry_block.tscn"), + Types.BlockType.EXECUTE: preload("res://addons/block_code/ui/blocks/statement_block/statement_block.tscn"), +} + + +static func instantiate_block(block_name: StringName) -> Block: + BlocksCatalog.setup() + var block_definition: BlockDefinition = BlocksCatalog.get_block(block_name) + if block_definition == null: + push_error("The block %s is not in the catalog yet!" % block_name) + return + + var scene = SCENE_PER_TYPE[block_definition.type] + var b = scene.instantiate() + b.block_name = block_definition.name + b.block_format = block_definition.label_template + b.statement = block_definition.code_template + b.defaults = block_definition.defaults + b.tooltip_text = block_definition.description + b.category = block_definition.category + if block_definition.type == Types.BlockType.ENTRY and block_definition.signal_name != "": + b.signal_name = block_definition.signal_name + return b + ## Polyfill of Node.is_part_of_edited_scene(), available to GDScript in Godot 4.3+. static func node_is_part_of_edited_scene(node: Node) -> bool: