WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 07-07-2008, 03:14 PM
Uttama_vizard Uttama_vizard is offline
Member
 
Join Date: Sep 2007
Posts: 60
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
Reply With Quote
 

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
Could not find plugin to load objects... halley Vizard 1 05-30-2006 11:01 AM
file input vsully Vizard 1 12-21-2004 10:51 PM
avatar head texture issues rconrey Vizard 3 11-17-2004 04:05 PM
Closing file handles from within function FlyingWren Vizard 1 10-01-2003 06:02 PM
I cannot show wrl file with text node sled Vizard 3 06-25-2003 07:52 AM


All times are GMT -7. The time now is 04:56 AM.


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