Setting Flags

See ExampleSripts Setting Flags

import sightlab_utils.sightlab as sl

from sightlab_utils.settings import *


sightlab = sl.SightLab()


#run sightlab experiment

import viztask

def sightLabExperiment():

yield viztask.waitKeyDown(' ')

yield sightlab.startTrial()

print('experiment start')

#Example that drops a flag when you press the ‘t’ key: 

def buttonTrigger():

sightlab.setCustomTrialData('T key pressed')

print("T key pressed")

vizact.onkeydown('t',buttonTrigger)


#Example of a flag that drops when you click the trigger on your controller. 

#This one gets the callback from an event you can create in your vizconnect file. 

#Default is either trigger with controllor or 'v' key

def rightHandTrigger(e):

sightlab.setCustomTrialData('sensor pressed')

print("sensor pressed")

viz.callback(viz.getEventID('triggerPress'), rightHandTrigger)

yield viztask.waitKeyDown(' ')

yield sightlab.endTrial()

print('experiment end')

#For manually using a button, such as a SteamVR controller trigger: 

if not sightlab.getConfig() in ['Desktop']:

import steamvr

import vizact

controller = steamvr.getControllerList()[1]

def controllerTest():

print('test')

vizact.onsensordown(controller,steamvr.BUTTON_TRIGGER, controllerTest)

viztask.schedule(sightlab.runExperiment)

viztask.schedule(sightLabExperiment)

vizact.onkeydown(' ',sightlab.startTrial)