From 9c854bc1b975f240928326aa9d8db28282735252 Mon Sep 17 00:00:00 2001 From: Ross Andrews Date: Mon, 8 Jun 2026 22:17:04 -0500 Subject: [PATCH] delay fn --- kiln-core/src/script.rs | 9 +++++++++ 1 file changed, 9 insertions(+) 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();