File tree Expand file tree Collapse file tree 4 files changed +35
-4
lines changed Expand file tree Collapse file tree 4 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1+ @tool
2+ extends BlockExtension
3+
4+ const OptionData = preload ("res://addons/block_code/code_generation/option_data.gd" )
5+
6+
7+ func get_defaults_for_node (context_node : Node ) -> Dictionary :
8+ var animation_player = context_node as AnimationPlayer
9+
10+ if not animation_player :
11+ return {}
12+
13+ var animation_list = animation_player .get_animation_list ()
14+
15+ return {"animation" : OptionData .new (animation_list )}
Original file line number Diff line number Diff line change 1- [gd_resource type ="Resource" load_steps =4 format =3 uid ="uid://c5e1byehtxwc0" ]
1+ [gd_resource type ="Resource" load_steps =5 format =3 uid ="uid://c5e1byehtxwc0" ]
22
33[ext_resource type ="Script" path ="res://addons/block_code/code_generation/block_definition.gd" id ="1_emeuv" ]
44[ext_resource type ="Script" path ="res://addons/block_code/code_generation/option_data.gd" id ="1_xu43h" ]
5+ [ext_resource type ="Script" path ="res://addons/block_code/blocks/graphics/animationplayer_play.gd" id ="2_7ymgi" ]
56
67[sub_resource type ="Resource" id ="Resource_vnp2w" ]
78script = ExtResource ("1_xu43h" )
@@ -16,14 +17,15 @@ description = "Play the animation."
1617category = "Graphics | Animation"
1718type = 2
1819variant_type = 0
19- display_template = "Play {animation: STRING } {direction: OPTION}"
20+ display_template = "Play {animation: OPTION } {direction: OPTION}"
2021code_template = "if \" {direction}\" == \" ahead\" :
21- play({animation})
22+ play(\" {animation}\" )
2223else:
23- play_backwards({animation})
24+ play_backwards(\" {animation}\" )
2425"
2526defaults = {
2627"direction" : SubResource ("Resource_vnp2w" )
2728}
2829signal_name = ""
2930scope = ""
31+ extension_script = ExtResource ("2_7ymgi" )
Original file line number Diff line number Diff line change @@ -64,5 +64,15 @@ func _init(
6464 extension_script = p_extension_script
6565
6666
67+ func get_defaults_for_node (parent_node : Node ) -> Dictionary :
68+ if not _extension :
69+ return defaults
70+
71+ # Use Dictionary.merge instead of Dictionary.merged for Godot 4.2 compatibility
72+ var new_defaults := _extension .get_defaults_for_node (parent_node )
73+ new_defaults .merge (defaults )
74+ return new_defaults
75+
76+
6777func _to_string ():
6878 return "%s - %s " % [name , target_node_class ]
Original file line number Diff line number Diff line change 11@tool
22class_name BlockExtension
33extends Object
4+
5+
6+ func get_defaults_for_node (context_node : Node ) -> Dictionary :
7+ return {}
You can’t perform that action at this time.
0 commit comments