CONDITION
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.
CONDITIONStableAvailable Variables- Fires
- On State Start · During State · On State Exit
Description
CONDITION is a plain JavaScript object — not a function — exposing the active values of your experiment's variables for the current trial. Keys are variable names you declared in the Configure experiment automation › Variables tab; values are the matching strings (or arrays, for compound types). Use it to make state-listening behavior depend on within-subjects or between-subjects design.
Parameters
Not a function. Indexed as CONDITION["yourVariableName"].
Side effects
- Reads only — no writes, no signals, no
$.groupStatemutations. ReadingCONDITIONdoesn't disturb experiment state. - Backed internally by
$.groupState.currentCondition, refreshed by the state machine at the start of each trial. - Lifecycle: within-subjects values swap at the boundary between
Trial - Restand the nextTrial - Start. Between-subjects values are set once per session and don't change for its duration. - Outside trial states (e.g., during
Endor before the firstTrial - Start),CONDITIONmay be empty or stale. If you need post-trial values, read them from$.groupState.currentConditiondirectly, or capture them intoCOLLECTED_DATAbefore the trial ends. - A misspelled key returns
undefined— there's no compile-time check. All values are strings unless your variable definition uses an array type.
Example
In Tutorial 3 (Stroop), the Stimulus × Trial - Start cell reads several within-subjects keys in a single Customized Action to drive both the visible text and its position:
// On State Start of Trial - Start
const fontColor = CONDITION["fontColor"]; // "red" or "blue"
const textMeaning = CONDITION["textMeaning"]; // "RED" or "BLUE"
const depth = CONDITION["depth"]; // "near" or "far"
SetText(textMeaning);
SetChildPosition("Stimulus", 0, depth === "near" ? 1.5 : 3.0, 0);
ShowItem();The same value is also passed alongside collected data so each row of the eventual CSV carries the condition it came from:
SendDataToCollector("fontColor", CONDITION["fontColor"]);
SendDataToCollector("textMeaning", CONDITION["textMeaning"]);Related
PARTICIPANTS— the other built-in global; together they answer "what condition is this trial?" and "who is playing?".- Reference → Variables →
CONDITION— the deeper write-up with caveats and lifecycle. - Concepts → Within vs. between subjects — where these values come from in the variable definitions.
- Tutorial 3 — Stroop Effect (Other sample) — uses
CONDITIONin essentially every trial-state listener.
Source
Assets/Doc/LUIDA-StateListeningItemScriptDoc.md
Original markdown body
- Only available if **LUIDA experiment progress automation feature is enabled and during the trial states** (e.g., `Trial - Start`, `Trial - Rest`).
- Contains values from your configured experimental variables for the current trial.
- Use `CONDITION["your_variable_name"]` to retrieve a specific condition value within the current trial.