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" ]
2
2
3
3
[ext_resource type ="Script" path ="res://addons/block_code/code_generation/block_definition.gd" id ="1_emeuv" ]
4
4
[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" ]
5
6
6
7
[sub_resource type ="Resource" id ="Resource_vnp2w" ]
7
8
script = ExtResource ("1_xu43h" )
@@ -16,14 +17,15 @@ description = "Play the animation."
16
17
category = "Graphics | Animation"
17
18
type = 2
18
19
variant_type = 0
19
- display_template = "Play {animation: STRING } {direction: OPTION}"
20
+ display_template = "Play {animation: OPTION } {direction: OPTION}"
20
21
code_template = "if \" {direction}\" == \" ahead\" :
21
- play({animation})
22
+ play(\" {animation}\" )
22
23
else:
23
- play_backwards({animation})
24
+ play_backwards(\" {animation}\" )
24
25
"
25
26
defaults = {
26
27
"direction" : SubResource ("Resource_vnp2w" )
27
28
}
28
29
signal_name = ""
29
30
scope = ""
31
+ extension_script = ExtResource ("2_7ymgi" )
Original file line number Diff line number Diff line change @@ -64,5 +64,15 @@ func _init(
64
64
extension_script = p_extension_script
65
65
66
66
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
+
67
77
func _to_string ():
68
78
return "%s - %s " % [name , target_node_class ]
Original file line number Diff line number Diff line change 1
1
@tool
2
2
class_name BlockExtension
3
3
extends 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