View Single Post
  #2  
Old 02-03-2010, 09:28 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You can modify a variable within a function by using the global keyword. Here pressing the spacebar modifies a variable and then prints it.
Code:
import viz
import vizact

viz.go()

var = 1

def addTwo():
	global var
	var += 2
	print var
	
vizact.onkeydown(' ',addTwo)
Reply With Quote