Skip to content

Adding Instructions

Located in ExampleScripts \Instructions

Overview

Here is how you can add instructions that will show up in a headset (wherever the user looks) and on the mirrored desktop view. This can be triggered using any event (such as a yield viztask.WaitTime ). This code is also under the "ExampleScripts" folder.  The default for skipping past the instruction is either with the left mouse click or controller trigger. 

Start and End Text

Use startExperimentText for instructions that show at the start of the experiment or startTrialText for text that shows at the start of each trial. 

yield sightlab.startTrial(startExperimentText="test", textContinueEvent="triggerPress")

End Experiment Text

yield sightlab.endTrial(endExperimentText="Done")

Example (note: \n will create a new line, creating two here for an extra space)

yield sightlab.startTrial(
    startExperimentText="Look Around the Room \n\n Press Trigger when Ready"
)

Example: Note, have the startCondition set to 'None' in the GUI for the first trial if using startExperimentText, as the trigger will be used (can be changed to another condition in the code). Subsequent trial start and stop conditions can be set in GUI or code.

#Add this code to the SightLabExperiment Function:
def sightLabExperiment():
 yield viztask.waitEvent(EXPERIMENT_START)

 for trial in range(sightlab.getTrialCount()):

  if sightlab.getTrialNumber() == 1:
   yield sightlab.startTrial(startExperimentText= 
   'Look Around the Room \n\n Press Trigger when Ready')
  else:
   yield viztask.waitEvent(TRIAL_START)

  yield viztask.waitKeyDown(' ')
  yield sightlab.endTrial()

viztask.schedule(sightlab.runExperiment)
viztask.schedule(sightLabExperiment)
viz.callback(viz.getEventID('ResetPosition'), sightlab.resetViewPoint)

One Other Method for using code

if i != 0:
    #event to start every subsequent trial
    yield viztask.waitKeyDown(' ')
    # — start trial once, with instructions only on trial 1 —
    if i == 0:
        yield sightlab.startTrial(
            startExperimentText = "Press Spacebar to Start",textContinueKey    = ' ')
    else:
        yield sightlab.startTrial()

Basic Instructions

Instructions with GUI and start condition set in GUI

def sightLabExperiment(): 
    yield viztask.waitEvent(EXPERIMENT_START)   
    yield viztask.waitTime(0.1)
    yield sightlab.showInstructions('Look Around the Room') 

    for trial in range(sightlab.getTrialCount()):
        yield viztask.waitEvent(TRIAL_START)
        yield sightlab.hideInstructions()

Basic Instructions that can be brought up anytime.

yield sightlab.showInstructions('test', pauseTimer = True)
yield viztask.waitEvent('triggerPress')
yield sightlab.hideInstructions()
yield sightlab.setDataLoggingState(1)

For instructions to show at the start, place showInstructions and waitEvent before sightlab.startTrial() . In this case you don't need hideInstructions or pauseTImer

def sightLabExperiment():
    yield viztask.waitEvent(EXPERIMENT_START)
    yield sightlab.showInstructions('Do Something.\n\n Click Trigger or Left Mouse Button To Start')
    yield viztask.waitEvent('triggerPress')
    for i in range(0, sightlab.getTrialCount()):
        yield sightlab.startTrial()

Can also use the same start condition as the trials, such as spacebar in this example

def sightLabExperiment():
    yield viztask.waitEvent(EXPERIMENT_START)
    yield sightlab.showInstructions("Press 'a' to toggle basketball \n\n Press Spacebar to Continue")
    for i in range(0, sightlab.getTrialCount()):
        yield viztask.waitKeyDown(' ')
        yield sightlab.startTrial()

Image Based Instructions

def sightLabExperiment():
 while True:
  #Press spacebar to cycle image instructions before first experiment starts
  sightlab.instructionsImageQuad.setScale([1,1.5,1])
  yield sightlab.showInstructions(image = 'sightlab_resources/sightlab_controls.jpg')
  yield viztask.waitKeyDown(' ')
  yield sightlab.showInstructions(image = 'sightlab_resources/sightlab_controls_oculus.jpg')
  sightlab.instructionsImageQuad.setScale([1.5,1,1])
  yield viztask.waitKeyDown(' ')
  yield sightlab.hideInstructions()

  while True:
   if not sightlab.getTrialNumber() == 1:
    yield viztask.waitKeyDown(' ')  
   yield sightlab.startTrial()
   yield viztask.waitKeyDown(' ')
   yield sightlab.endTrial()
viztask.schedule(sightlab.runExperiment)
viztask.schedule(sightLabExperiment)

Find also examples for adding multiple images or instruction text slides in the ExampleScripts

Another option for adding instructions at specific times and after certain conditions is to use a STIM file

You can also download a .jpg of an instructions (such as creating a slide in Google slides and downloading as a .jpg) then adding that .jpg to your 3d scene by using File-Add. You can then move the image by right clicking and choosing "Add-Transform" to use the move tools. This model with the instructions can then be added as a trial with tracking turned off.

Was this page helpful?