LUIDA Docs

ToNextState

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.

ToNextState()StableState Machine Control
Fires
On State Start · During State · On State Exit

Description

Triggers a transition to the next experiment state.

Parameters

No parameters.

Side effects

  • Sends the signal state_triggerTransition to the item's own scope ($.sendSignalCompat("this", "state_triggerTransition")).
  • The state machine controller listens for this signal and advances the global state_currentID to the next state.
  • No state writes, no $.groupState mutations, no callExternal. The actual transition (entering the new state, firing state_enter / state_exit) is the state machine's job.
  • The same effect is produced by the Luida To Next State Gimmick CCK component, which the answer-button pattern uses instead of a Customized Action.

Example

In Tutorial 3 (Stroop), CalculationTextInput's top-level onTextInput callback calls ToNextState() directly when the participant submits an arithmetic answer:

function getRandomInt(max) {
  return Math.floor(Math.random() * max);
}
$.onTextInput((text, meta, status) => {
  if (status === TextInputStatus.Success) {
    ToNextState();
  }
});

When the participant submits, the state machine advances out of CalculationTask to whatever's next in the state list.

For the answer buttons themselves, Stroop uses the higher-level Luida To Next State Gimmick (which fires the same signal under the hood) so no JavaScript is needed — just an Interact Item Trigger configured to send the toNextState signal.

Source

Assets/Doc/LUIDA-StateListeningItemScriptDoc.md