WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   Saving/Loading data (

TrashcanPatrol 11-18-2008 01:11 PM

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?

Jeff 11-19-2008 11:24 AM

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.

TrashcanPatrol 12-02-2008 03:23 PM

The code is not working for me... I keep getting this error from it:

Traceback (most recent call last):
File "", line 11, in ?
File "", line 85, in ?
score_data = open('quest_data','a')
TypeError: 'VizText' object is not callable

farshizzo 12-02-2008 03:59 PM

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.

TrashcanPatrol 12-04-2008 01:20 PM

The tutorial mentioned above uses the same code and it works, though...


import viz

import time


subject = viz.input('What is the participant number?')
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)




yes_button = viz.add(viz.BUTTON)

no_button = viz.add(viz.BUTTON)

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.
    #Flush the internal buffer.
    #Close the world.


In this, the file they're trying to open is duck_data; my file is called score_data, is that too generic?

Jeff 12-05-2008 04:02 PM

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

TrashcanPatrol 12-09-2008 03:04 PM

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!

billjarrold 06-20-2012 10:29 AM

thanks - saved me time
thanks for making this post. it saved me a lot of debugging time!

All times are GMT -7. The time now is 08:53 PM.

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