var = 10
 
##############################
 
ear.addCommand("plus one", "python", "plusone")
ear.addCommand("minus one", "python", "minusone")
ear.addCommand("what's the value", "python", "thevalue")
 
##############################
 
 
def plusone():
    mouth.speak("plus one")
    var += 1
 
def minusone():
    mouth.speak("minus one")
    var -= 1
 
def thevalue():
    mouth.speak("the value is" + str(var))

Alessandruino

10 years 5 months ago

Write global var at the begin of every function:

Example :

def example():
global var
var +=1
print var