fc2008
07-17-2008, 01:18 PM
Heya im getting this error, im trying to make it so when the left mouse button is pressed an event occurs,
but i Keep getting the following error:
if info.valid and info.object == female:
UnboundLocalError: local variable 'info' referenced before assignment
any thoughts? the code is below:
import viz
import vizinfo
viz.go()
ground = viz.add('tut_ground.wrl')
avatar = viz.add('vcc_male.cfg')
female = viz.add('vcc_female.cfg')
viz.translate(viz.HEAD_POS,0,20,-30)
viz.lookat(0,0,0)
viz.mouse(viz.OFF)
viz.clearcolor(0.5,0.5,1)
#Add the vizinfo object with a message.
infoObject = vizinfo.add('Give me feedback!')
infoObject.visible(0)
#Give it a title.
infoObject.title('Vizinfo box')
#Add GUI elements with labels.
button = infoObject.add(viz.BUTTON, 'Push me')
slider = infoObject.add(viz.SLIDER, 'Slide me')
check = infoObject.add(viz.CHECKBOX, 'Check me')
#Adjust the parameters of one of the GUI elements.
slider.vertical()
def mouse(button):
if button == viz.MOUSEBUTTON_LEFT:
info = viz.pick(1)
if info.valid and info.object == ground:
walk = vizact.walkTo([info.point[0],0,info.point[2]])
avatar.runAction(walk)
if info.valid and info.object == female:
infoObject.visible(1)
viz.callback(viz.MOUSEDOWN_EVENT,mouse)
thankyou for your time
but i Keep getting the following error:
if info.valid and info.object == female:
UnboundLocalError: local variable 'info' referenced before assignment
any thoughts? the code is below:
import viz
import vizinfo
viz.go()
ground = viz.add('tut_ground.wrl')
avatar = viz.add('vcc_male.cfg')
female = viz.add('vcc_female.cfg')
viz.translate(viz.HEAD_POS,0,20,-30)
viz.lookat(0,0,0)
viz.mouse(viz.OFF)
viz.clearcolor(0.5,0.5,1)
#Add the vizinfo object with a message.
infoObject = vizinfo.add('Give me feedback!')
infoObject.visible(0)
#Give it a title.
infoObject.title('Vizinfo box')
#Add GUI elements with labels.
button = infoObject.add(viz.BUTTON, 'Push me')
slider = infoObject.add(viz.SLIDER, 'Slide me')
check = infoObject.add(viz.CHECKBOX, 'Check me')
#Adjust the parameters of one of the GUI elements.
slider.vertical()
def mouse(button):
if button == viz.MOUSEBUTTON_LEFT:
info = viz.pick(1)
if info.valid and info.object == ground:
walk = vizact.walkTo([info.point[0],0,info.point[2]])
avatar.runAction(walk)
if info.valid and info.object == female:
infoObject.visible(1)
viz.callback(viz.MOUSEDOWN_EVENT,mouse)
thankyou for your time