WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-17-2008, 01:18 PM
fc2008 fc2008 is offline
Member
 
Join Date: Jul 2008
Posts: 6
what does this error code mean?

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:

Code:
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
Reply With Quote
  #2  
Old 07-17-2008, 04:17 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You are creating the info variable in a different indentation block than the if statement. So if the right mouse button was clicked you would get an error because the info object would never be created. So you need to indent the if info.valid and info.object == female: block so it is in the same scope as the line info = viz.pick(1)
Reply With Quote
  #3  
Old 07-17-2008, 05:38 PM
fc2008 fc2008 is offline
Member
 
Join Date: Jul 2008
Posts: 6
Thumbs up thanks

cheers, thats sorted a lot of the problems ive been havin

Also I was wondering if there could be a scripts page in the future on here, so users can share scripts etc?

Thankyou for your time
Reply With Quote
Reply

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


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


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