If you want PsyScript to display an image, or play a sound or a movie, you first need to load it into a cell. There are 26 cells, named 'A' to 'Z', and you can have them all visible and active at the same time, though if you try to play 26 movies at once your computer may not be able to play them all smoothly.
There are separate help pages on images, sounds, movies, text fields and sliders, but this page continues with information about the commands which apply no matter what a cell holds. For grammatical simplicity, the text will talk about images, but it applies to sounds and movies.
At the beginning of your script, all 26 cells are hidden and in unknown positions. To make an image appear on the screen you need to do three things:
The order of the first two doesn't matter, but you should do both of them before making the cell visible, unless you want your participant to be able to see the cell changing content or position. On the other hand, if you don't mind this, particularly if your experiment involves having a participant watch a changing image, or a moving image, these commands may be executed in any order.
The smallest amount of code required to show an image would be …
Cell positions are specified using two coordinates: horizontal (the bigger the number, the further to the right) and vertical (the bigger the number, the lower). The position (0,0) always refers to the middle of the screen, no matter how big your screen is.
So you can develop your script on a desktop computer with a big screen, then run it on a laptop with a small screen, and something shown at (0,0) will be still be in the middle, and something at (-50,0) will still be slightly to the left of centre. However, because the screens are different sizes, (-900,0) may be visible on the left of the desktop display, but it may be so far off the left of the laptop display that the cell isn't visible at all. So if you intend to test on a different computer to the one you're writing your script on, test your script on that computer early on, to decide what coordinates to use when positioning cells and how big your stimuli should be.
You can find out the value of a cell by referring to the appropriate variable:
This is really only intended for use with text cells. The value of a text cell is whatever string of text the cell contains. But can still use this value with a cell containing an image, sound or movie. If you do, then the value returned will be the full path of the file the cell contains.
To ensure reproducability, you can do any number of commands with any number of image cells and the results of these commands will not be visible to the participant until a wait command is executed. At that time, just before the script pauses to wait for the participant to do something, the display will change to reflect all changes since the last wait. So if you lots of cells to move, show and hide before allowing your participant to see all the changes, it doesn't matter what order you issue all the commands in: the display will stay the same until it suddenly updates when PsyScript executes the next wait command.
However, if you use the play command with sounds or movies, the sound or movie may begin playing immediately the command is executed. Unfortunately different browsers implement these commands differently. Therefore if you have any complicated interaction between things playing and becoming visible or invisible, it's best to test on many browsers, or to use only a browser you've tested on.
move cell value to (value,value)
Moves a cell to a specific position relative to the centre of the screen.
move cell A to (400,600)
move cell P to ($varX, $varY)
move cell $varTargetCell to (0,0)
move cell value to centre
Moves a cell to the centre of the screen.
move cell A to centre
move cell $varTargetCell to centre
show cell value
Makes a cell visible, assuming it is loaded with something which can be seen and positioned on the screen. If the cell is already being 'shown', does nothing.
show cell L
show cell $varNewCell
hide cell value
Makes a cell invisible. If the cell is already invisible, does nothing.
hide cell R
hide cell $lastClick