Await Section (Section) — skLambda
Addon: skLambda · Category: Section · Since: 1.3.0
Syntax
wait for next <.+>Description
Pauses the trigger until an event fires (or an optional timeout elapses), then continues with the code that follows. The section body runs when the awaited event arrives, with that event's values in scope (e.g. `message` for `chat`). An optional `on timeout:` block, nested inside the section alongside the body, runs instead if the timeout elapses; it runs in the original event's context (the awaited event never fired). Whichever branch runs, locals it sets carry forward, so the linear code after the block can read them. `wait for next <event> [where <condition>] [(within|for at most) <timespan>]:` Filter with a trailing `where` clause; the timeout clause comes last. Without a timeout the await waits indefinitely, so it will show in `/sklambda listeners` and the leak notifier; prefer giving one. Because the awaited event has already dispatched by the time the body runs (and async events resume on the main thread the next tick), the body cannot cancel or modify the triggering event.
Examples
set {_p} to sender
send "say something in chat within 30 seconds..." to {_p}
wait for next chat where player is {_p} for at most 30 seconds:
set {_reply} to message
on timeout:
set {_reply} to "<no reply>"
send "you said: %{_reply}%" to {_p}