Sleep
These pages are not yet fully reviewed. The LUIDA team is continuing to review and improve them. If you find anything wrong on these pages, or have questions that aren't resolved by reading them, please ask or report to the LUIDA team.
Sleep(seconds)StableUser Feedback & Utilities- Fires
- On State Start · During State · On State Exit
Description
Pauses the execution of subsequent actions in the current list for a specified duration. Note: This has no direct ClusterScript function equivalent.
Parameters
| Name | Type | Description |
|---|---|---|
seconds | number |
Side effects
- No state writes, no signals, no
$.groupStatemutations. Sleep is a marker action emitted as{ type: "sleep", value: <seconds> }in the generated action list. StateListeningItemBase.jsadvances the action chain inOnStateEnter/OnStateExituntil it hits a sleep marker, then defers further actions untiltimer >= secondsof accumulateddeltaTime.- Only meaningful inside
On State StartorOn State Exitchains.DuringStateruns every frame and skips sleep markers (if (... === "sleep") $.state.duringStateActionID += 1; else ...), so blocking on Sleep there is a no-op — and trying to "wait between per-frame steps" usually means you wanted a Customized Action with your own timer.
Example
A clean inter-stimulus interval — flash a stimulus for 1.5 s on state enter, then hide it:
// On State Start
ShowItem();
SetText("Press the matching button.");
Sleep(1.5);
HideItem();The action chain pauses at Sleep(1.5); after 1.5 s of accumulated deltaTime the runtime resumes and runs HideItem() on the next frame.
For longer pauses tied to a state itself (e.g. a 3-second rest screen), prefer setting an exit timer on the state in the State Machine tab — it's clearer in the UI and works with any action type.
Related
Customized Actionvs separate state-listening item — Sleep is borderline; if you need conditional or branching delays, a Customized Action with$.state.timer += deltaTimeis more flexible.- Concepts → State machine & trial lifecycle — when each lifecycle slot fires; explains why Sleep behaves differently in
On State Start/ExitvsDuring State. - Tutorial 2 → Trial - Rest break — uses an exit-timer-on-state instead of
Sleep()for the same effect.