Play an Image sequence once
Record ID: one_shot. Global Script: off. Create animation_lab with the Image anim_arrow and four distinct frame IDs at 6 FPS, as in Chapter 3. Show that GUI before running this example.
extends "res://scripts/runtime/script_base.gd"func run(_context: Dictionary = {}) -> Variant:
var values: Dictionary = Runtime.get("variables")
if bool(values.get("ui_busy", false)):
return false
var manager: Node = Runtime.get("authored_gui_manager")
var nodes: Dictionary = manager.get("element_nodes")
var host: Control = nodes.get("anim_arrow") as Control
if not is_instance_valid(host):
return false
var image: PCAGUISpritePlayer = host.get_node_or_null("GUIContentImage")
if not is_instance_valid(image):
return false
await SetVariable({"name":"ui_busy", "value":true})
image.loop_animation = false
image.restart()
await get_tree().create_timer(4.0 / 6.0).timeout
if is_instance_valid(image):
image.playing = false
await SetVariable({"name":"ui_busy", "value":false})
return trueThe script restarts the native Image player, disables looping and holds the last frame. Adapt the element ID and the duration together when using a chest-lid or page-turn drawing.
The example uses a four-frame, 6-FPS schedule. If you change the frame count or rate, change the wait as well. Keep live inventory/save widgets separate from the moving drawing.
