![]() |
|
|
|
#1
|
|||
|
|||
|
In this code the hotspot is triggered and data is written to the file. When you click on the ball, that data is also witten to the file. Is this helpful?
Code:
import viz
viz.go()
room=viz.add('court.ive')
ball = viz.add('ball.wrl', pos = [0,1,5])
subject = viz.input('Who are you?')
#open file to append to
score_data = open('quest_data.txt','a')
#write to file when hotspot triggered
def onHotspot(id,x,y,z):
print "in hot spot"
data = 'Mr. ' + str(subject) + ' entered the hotspot.' + '\n'
score_data.write(data)
#Callback the hotspot event.
viz.callback(viz.HOTSPOT_EVENT,onHotspot)
viz.starthotspot(1,viz.RECTANGLE_HOTSPOT_IN,0,0,.5,.5)
#write to file when object is picked
def ballPicked():
print "ball picked"
score_data.write('Mr. ' + str(subject) + ' picked the ball.' + '\n')
vizact.onpick(ball, ballPicked)
#close the file when program is ended
vizact.onexit(score_data.close)
|
|
#2
|
|||
|
|||
|
Ah yes! It works now! Thank you very much for your help
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| writing joystick position to a data file | Saz | Vizard | 3 | 12-17-2008 06:18 AM |
| Crashing when I select Tracker option | GoldenSun | Vizard | 4 | 07-01-2008 12:06 PM |
| Flagging the Data | Elittdogg | Vizard | 5 | 04-11-2008 12:40 PM |
| Writing text files with executable | adimov | Vizard | 1 | 03-21-2008 04:21 PM |
| tracking using quaternarion data | jfreeman | Vizard | 2 | 06-01-2005 09:48 AM |