Hi,
Thank you for the reply!
I got the following to work. I will try your example also tomorrow. Perhaps both ways of turning the boxes on and off will be useful as I get more complex with the code.
Thanks,
Karla
Code:
#******************************************************************************************
#******************************************************************************************
#Sequence of interaction between avatar and user with avatar smiling and talking
#******************************************************************************************
#******************************************************************************************
import viz
import vizinfo #For message box
import viztask #For wait time
viz.go()
male = viz.add('male.cfg') #Add an avatar
male.translate(0,0,1)
male.rotate(0,1,0,180)
male.state(1) #Start in neutral state animation
face2 = male.face('biohead_talk.vzf') #add a face to the avatar
smile = vizact.morph(0,2,0.5) #Smiling face of male avatar
open = vizact.morph(5,0.5,0.5) #mouth open morph of male avatar
#Setting some info boxes
charTalkA = vizinfo.add("It's nice to meet you.")
charTalkA.translate(1.0,.95) #Set position on screen
charTalkA.title("Chat Box") #Give it a title.
charTalkA.visible(viz.OFF) #turn view off
charTalkB = vizinfo.add("Uh, that's personal. I'm Alex. Who are you?")
charTalkB.translate(1.0,.95) #Set position on screen
charTalkB.title("Chat Box") #Give it a title.
charTalkB.visible(viz.OFF) #turn view off
def displayAction(some_box, sec):
some_box.visible(viz.ON)
viz.waittime(sec)
some_box.visible(viz.OFF)
# Make an action when a key is pressed.
def mykey(key):
global subTalk, OKbutton, aRadio, bRadio, cRadio, charTalk
if key == ' ': #if the pressed key is space bar
face2.add(smile) #Smiling face of male avatar
face2.add(open) #Open mouth face of male avatar
male.state(5) #Wave animation of male avatar
#Show a Transparent Message Box
if key == '5': #if the pressed key is '5'
subTalk = vizinfo.add("") #Add the vizinfo object
subTalk.translate(1.0,.95) #Set position on screen
subTalk.title("Chat Box") #Give it a title.
subTalk.visible(viz.ON) #Display the Message Box
aRadio = subTalk.add(viz.RADIO, 0, "Hello.") #Create a Radio button
bRadio = subTalk.add(viz.RADIO, 0, "What is your street address?")
cRadio = subTalk.add(viz.RADIO, 0, "What is your pet's name?")
astext = "Hello."
bstext = "What is your street address?"
cstext = "What is your pet's name?"
OKbutton = subTalk.add(viz.BUTTON, "OK") #Create a button
print aRadio.get()
viz.callback(viz.KEYBOARD_EVENT,mykey)
# Make an action when a BUTTON is pressed.
def onButton (button,state):
global subtalk, OKbutton, aRadio, bRadio, cRadio, charTalk
if button == OKbutton and state == viz.DOWN:
aans = aRadio.get()
bans = bRadio.get()
cans = cRadio.get()
subTalk.visible(viz.OFF) #Remove the Message Box
if aans == 1:
viz.director(displayAction, charTalkA, 1)
print "A."
elif bans == 1:
viz.director(displayAction, charTalkB, 2)
print "B."
elif cans == 1:
viz.director(displayAction, charTalkB, 3)
print "C."
else:
print "none"
print bans
else:
print "place holder"
viz.callback(viz.BUTTON_EVENT, onButton)
def mytimer(num):
viz.callback(viz.TIMER_EVENT,mytimer)
viz.starttimer(0,0.01,viz.FOREVER)
#***********************************************************
#Adding a world
#***********************************************************
room = viz.add('panorama.ive')
room.scale(1,1,1) # scale actual
room.translate(0,0,0) # position in the world