|  | 
| 
			 
			#1  
			
			
			
			
			
		 | |||
| 
 | |||
| 
				
				Saving/Loading data
			 
			
			Hi, I've been wondering what is possible with Vizard to do in the case of saving and loading data? I've found a post here that shows how to output the keystrokes to a text file, but I'm trying to save things such as what options were selected at a text box, if the player has already "talked" to an avatar, etc. What are the options for this? | 
| 
			 
			#2  
			
			
			
			
			
		 | |||
| 
 | |||
| 
			
			Here's a link to a tutorial on creating data files.  If you have further questions on writing your data to file let me know. http://www.worldviz.com/vizhelp/Creating_data_files.htm | 
| 
			 
			#3  
			
			
			
			
			
		 | |||
| 
 | |||
| 
			
			The code is not working for me... I keep getting this error from it: Quote: 
 | 
| 
			 
			#4  
			
			
			
			
			
		 | |||
| 
 | |||
| 
			
			This means you have assigned a text object to a variable named open, which conflicts with the built-in Python function. You should rename your text objects to something less generic.
		 | 
| 
			 
			#5  
			
			
			
			
			
		 | |||
| 
 | |||
| 
			
			The tutorial mentioned above uses the same code and it works, though... Code: import viz
import time
viz.go()
subject = viz.input('What is the participant number?')
viz.add('duck.cfg').translate(0,0,4)
critical_question = viz.add(viz.TEXT3D,'Do you see a duck?',viz.SCREEN)
yes = viz.add(viz.TEXT3D, 'Yes!',viz.SCREEN)
no = viz.add(viz.TEXT3D, 'No!',viz.SCREEN)
critical_question.alignment(viz.TEXT_CENTER_TOP)
critical_question.translate(.5,.9)
yes.alignment(viz.TEXT_LEFT_TOP)
yes.translate(.25,.75)
no.alignment(viz.TEXT_LEFT_TOP)
no.translate(.75,.75)
yes_button = viz.add(viz.BUTTON)
yes_button.translate(.22,.71)
no_button = viz.add(viz.BUTTON)
no_button.translate(.72,.71) 
start_time = time.time()
question_data = open('duck_data','a')
def onbutton(obj,state):
    #Use our starting time variable to find out how much
    #time has elapsed.
    elapsed_time = time.time() - start_time
    #Create string lines to put in the data file, depending on which
    #button was pushed.
    if obj == yes_button:
        data = 'Subject ' + str(subject) + ' saw a duck.'
    if obj == no_button:
        data = 'Subject ' + str(subject) + ' did not see a duck.'
    #Write the data to our file.
    question_data.write(data)
    #Flush the internal buffer.
    question_data.flush()
    #Close the world.
    viz.quit()
viz.callback(viz.BUTTON_EVENT,onbutton) | 
| 
			 
			#6  
			
			
			
			
			
		 | |||
| 
 | |||
| 
			
			the problem is not the name of your file, score_data.  Somewhere else in your script you have a variable named open.  You'll just need to give that a new name
		 | 
| 
			 
			#7  
			
			
			
			
			
		 | |||
| 
 | |||
| 
			
			Ah yes, I looked around for 'open' and it seems I had forgotten that I had a text object outside of the script so it was on the stage. No wonder I was having so much trouble finding it... thanks for the help!
		 | 
| 
			 
			#8  
			
			
			
			
			
		 | |||
| 
 | |||
| 
				
				thanks - saved me time
			 
			
			thanks for making this post.  it saved me a lot of debugging time!
		 | 
|  | 
| Thread Tools | |
| Display Modes | Rate This Thread | 
| 
 | 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Crashing when I select Tracker option | GoldenSun | Vizard | 4 | 07-01-2008 11:06 AM | 
| Flagging the Data | Elittdogg | Vizard | 5 | 04-11-2008 11:40 AM | 
| data glove navigation | arielasso | Vizard | 6 | 10-24-2007 02:15 PM | 
| Data Files | betancourtb82 | Vizard | 6 | 05-04-2006 02:43 PM | 
| tracking using quaternarion data | jfreeman | Vizard | 2 | 06-01-2005 08:48 AM |