WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-18-2008, 01:11 PM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
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?
Reply With Quote
  #2  
Old 11-19-2008, 11:24 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,465
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
Reply With Quote
  #3  
Old 12-02-2008, 03:23 PM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
The code is not working for me... I keep getting this error from it:
Quote:
Traceback (most recent call last):
File "<string>", line 11, in ?
File "quest.py", line 85, in ?
score_data = open('quest_data','a')
TypeError: 'VizText' object is not callable
Reply With Quote
  #4  
Old 12-02-2008, 03:59 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
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.
Reply With Quote
  #5  
Old 12-04-2008, 01:20 PM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
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)
In this, the file they're trying to open is duck_data; my file is called score_data, is that too generic?
Reply With Quote
  #6  
Old 12-05-2008, 04:02 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,465
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
Reply With Quote
  #7  
Old 12-09-2008, 03:04 PM
TrashcanPatrol TrashcanPatrol is offline
Member
 
Join Date: Aug 2008
Posts: 43
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!
Reply With Quote
  #8  
Old 06-20-2012, 10:29 AM
billjarrold billjarrold is offline
Member
 
Join Date: Jul 2009
Location: San Francisco Bay Area
Posts: 39
thanks - saved me time

thanks for making this post. it saved me a lot of debugging time!
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
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


All times are GMT -7. The time now is 08:34 AM.


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