Before reading this section you should first read about cells.
Sliders are good for reaction scales. There are two kinds of sliders: continuous and graduated. A continuous slider has set endpoints at two numbers, and the user can position the slider to any position between those two endpoints. A graduated slider has set endpoints and a stepsize. As the user tries to move the slider thumb along the line, it will snap to the 'steps'.
The smallest amount of code required to show a continuous slider would be …
The above code will allow the slider thumb to be positioned to any point between 1 and 20, for instance depending on how many pixels the slider is long, it might be possible to set that slider to a position corresponding to 4.83.
To use a graduated slider and have the slider snap to positions regularly spaced along the scale you add a stepsize to the command:
You can find out the position of a slider (for comparison or logging purposes) by referring to the appropriate variable, for instance …
If you've already set up a slider you can change its value using
Setting up a graduated slider and setting its position to somewhere not on the graudations may work differently in different browsers. Don't do this is you want predictable results.
Your participant can move a slider using the mouse. If you want to allow this you normally put a button on the display that they can click when they're finished making their change – make an image that looks like a button, use an image cell to display it, and wait for a click on that cell. However, PsyScript gives you many other ways to limit their usage. For example you could use a command like wait for 20 seconds.
load cell value with slider from value to value
Sets up a continuous slider cell for the range supplied.
load cell S with slider from 1 to 20
load cell S with slider from 1 to $varTopValue
load cell S with slider from $varBottomValue to $varTopValue
load cell value with slider from value to value step value
Sets up a graduated slider cell for the range supplied.
load cell S with slider from 1 to 7 step 1
load cell S with slider from 0 to 6 step 2
load cell S with slider from 1 to $varTopValue step 1
load cell S with slider from $varBottomValue to $varTopValue step 10
set slider cell value to value
Sets the position of an existing slider cell to something new.
set slider cell C to 40
set text cell C to $varDefaultPosition