Hello,
This is a portion of my code....
import viz
import vizinfo
import viztask
import vizmat
import vizact
viz.go()
#These are for initializing the file
file5 = open('response_demo1_repeated_d_button.txt', 'w')
out = ''
file5.write(out)
file5.flush()
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)
sound_Instruction1.play()
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'
file5.write(out)
file5.flush()
lastKey = key
lastKeyTime = viz.tick()
viz.callback(viz.KEYDOWN_EVENT,onKeyDown)
The error which I am getting....
Traceback (most recent call last):
File "Sum08_Demo1_NEC_1A_4p5F.py", 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.
Uttama
|