WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-09-2009, 04:44 AM
katewilmut katewilmut is offline
Member
 
Join Date: May 2009
Posts: 6
Jeff,

I have tried using the help and could get any further - below is the code I am using. At I said before the loop at the bottom just gets stuck and does iterate onwards for each button press.

Any help is greatly appreciated

Kate

Code:
import viz
import math
import viztask
import random
import vizjoy

viz.go()

subject = viz.input('What is the participant number?')

viz.move(0,0,0)
viz.eyeheight(0)

Trial = 0
myTracker = viz.add('flockofbirds.dls') 
myTracker.reset()
viz.tracker()
ball=viz.add('soccerball.ive')
ballinitial = [0,0,8]
ball.setPosition(ballinitial)
	
def onKeyDown (key):
	viz.callback( viz.TIMER_EVENT, mytimer )
	viz.starttimer(0, 1/100, 5) 
	
def mytimer(num):
	print Trial
	data = myTracker.get()
	print data
	a = data[0]
	b = data[1]
	c = data[2]
	d = data[3]
	e = data[4]
	f = data[5]
	tracking_data = open('tracking_'+ str(subject) + '_' + str(Trial) + '.xls', 'a')
	tracking_data.write(str(a) + '	' + str(b) + '	' + str(c) + '	' + str(d) + '	' + str(e) + '	' + str(f) + '\n')
		
for i in range (0,9):	
	global Trial
	Trial = i
		viz.callback(viz.KEYDOWN_EVENT, onKeyDown)
Reply With Quote
  #2  
Old 06-10-2009, 12:31 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You loop should work, but there is no connection between it and your callbacks. It loops through and then leaves Trial set to a value of 8. If you want Trial to update each time a key is pressed then increment it in your keyboard callback function.
Code:
Trial = 0
def onKeyDown(key):
	global Trial	
	Trial += 1
	
viz.callback(viz.KEYDOWN_EVENT, onKeyDown)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing data more than once TrashcanPatrol Vizard 2 01-06-2009 03:56 PM
writing joystick position to a data file Saz Vizard 3 12-17-2008 05:18 AM
Flagging the Data Elittdogg Vizard 5 04-11-2008 11:40 AM
Writing text files with executable adimov Vizard 1 03-21-2008 03:21 PM
Data Files betancourtb82 Vizard 6 05-04-2006 02:43 PM


All times are GMT -7. The time now is 01:00 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC