Skip to content

Commit

Permalink
Await until animation is finished
Browse files Browse the repository at this point in the history
Add an option for playing the animation and waiting until it's done. The
previous behavior is now another option "play in the background".

For editing these block definition options in the Inspector, the class
name is back to OptionData.
  • Loading branch information
manuq authored and dylanmccall committed Oct 10, 2024
1 parent 093f362 commit 0f8d008
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions addons/block_code/blocks/graphics/animationplayer_play.tres
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_resource type="Resource" load_steps=6 format=3 uid="uid://c5e1byehtxwc0"]
[gd_resource type="Resource" load_steps=7 format=3 uid="uid://c5e1byehtxwc0"]

[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_emeuv"]
[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_xu43h"]
Expand All @@ -14,6 +14,11 @@ script = ExtResource("1_xu43h")
selected = 0
items = ["forward", "backwards"]

[sub_resource type="Resource" id="Resource_17pec"]
script = ExtResource("1_xu43h")
selected = 0
items = ["until done", "in the background"]

[resource]
script = ExtResource("1_emeuv")
name = &"animationplayer_play"
Expand All @@ -22,15 +27,18 @@ description = "Play the animation."
category = "Graphics | Animation"
type = 2
variant_type = 0
display_template = "play {animation: STRING} {direction: NIL}"
display_template = "play {animation: STRING} {direction: NIL} {wait_mode: NIL}"
code_template = "if {direction} == \"forward\":
play({animation})
else:
play_backwards({animation})
if {wait_mode} == \"until done\":
await animation_finished
"
defaults = {
"animation": SubResource("Resource_qpxn2"),
"direction": SubResource("Resource_vnp2w")
"direction": SubResource("Resource_vnp2w"),
"wait_mode": SubResource("Resource_17pec")
}
signal_name = ""
scope = ""
Expand Down

0 comments on commit 0f8d008

Please sign in to comment.