diff --git a/kiln-core/src/script.rs b/kiln-core/src/script.rs index 1b4ff6e..87d4454 100644 --- a/kiln-core/src/script.rs +++ b/kiln-core/src/script.rs @@ -464,6 +464,15 @@ fn register_write_api(engine: &mut Engine, queues: &QueueMap) { } }); + // delay(secs): insert an explicit pause into the queue, merged with any trailing Delay. + let q = queues.clone(); + engine.register_fn("delay", move |ctx: NativeCallContext, secs: f64| { + let src = source_of(&ctx); + if let Some(queue) = q.borrow().get(&src) { + push_delay(queue, secs.max(0.0)); + } + }); + // now(): pop the back of the queue and push it to the front. // Use after a zero-cost action (say, log) to bypass any pending Delay. let q = queues.clone();