View Single Post
Old 07-07-2008, 03:14 PM
Uttama_vizard Uttama_vizard is offline
Join Date: Sep 2007
Posts: 60

This is a portion of my code....

import viz
import vizinfo
import viztask
import vizmat
import vizact


#These are for initializing the file
file5 = open('response_demo1_repeated_d_button.txt', 'w')
out = ''

key = None
lastKey = None
lastKeyTime = 0.0
timer1 = 1
timer2 = 2

def StartStory():

#Set variables
count = 0
pool_number = 3
x_count = 0
y_count = 0

yield viztask.waitTime(2)

while count<1:

....some actions the avatar is performing...

yield onKeyDown(key)

def onKeyDown(key):
global lastKey,lastKeyTime

elapsed = viz.tick() - lastKeyTime

file6 = open('response_demo1_repeated_d_button.txt', 'r+')

if key == 'd' and lastKey != 'a' and lastKey != 'b' and lastKey != 'c' and elapsed < 100:
out = 'n'

lastKey = key
lastKeyTime = viz.tick()


The error which I am getting....

Traceback (most recent call last):
File "", line 1880, in onKeyDown
file6 = open('response_demo1_repeated_d_button.txt', 'r+') # opens file 'response_demo1_instructionscreen.txt' for reading
TypeError: 'ActionData' object is not callable

The code in blue is at line 1880.
In fact, when on multiple press of my 'd' key, I am seeing that the .txt file has a number of 'n'. I am trying to read these muliple 'n' (representing 'd' key press).

When I am placing the blue line on top, there is no error, but, in that case I cannot open my .txt file multiple times to get its updated contents. Actually, on every press of 'd' key, I will get an additional 'n' which I want to read.

Actually I am confused with the ActionData error when simply I am trying to open a .txt file.

Thanks in advance for the suggestion.

Reply With Quote