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_triggerTransitionto the item's own scope ($.sendSignalCompat("this", "state_triggerTransition")). - The state machine controller listens for this signal and advances the global
state_currentIDto the next state. - No state writes, no
$.groupStatemutations, nocallExternal. The actual transition (entering the new state, firingstate_enter/state_exit) is the state machine's job. - The same effect is produced by the
Luida To Next State GimmickCCK 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.
Related
- Conditional execution —
ToNextState()is often gated on aCONDITIONvalue (e.g. only advance when the participant chose the correct answer). - Tutorial 2 → CalculationTextInput —
ToNextState()in aCustomized Actionto advance after a text submit.