![]() |
|
#1
|
|||
|
|||
Thank you very much, actually the use of a global variable cross my mind but... it didn´t work... this is my code with the global variable "estadoPuerta" (door status)
estadoPuerta = 0 #Global Variable def clickIzquierdo(): #Left button action objeto = viz.pick() if objeto == puerta: if estadoPuerta == 0: abrePuerta() else: if estadoPuerta == 1: cierraPuerta() vizact.onmousedown(viz.MOUSEBUTTON_LEFT,clickIzqui erdo) def abrePuerta(): #Open door puerta.runAction(vizact.spinTo(euler = [-90,0,0], speed = 10.0)) # Euler(Y,X,Z) estadoPuerta = 1 sonido_abre.play() #Asignar sonido al picarle al boton de la puerta vizact.onkeydown("x",abrePuerta) def cierraPuerta(): #Close door puerta.runAction(vizact.spinTo(euler = [0,0,0], speed = 10.0)) # Euler(Y,X,Z) estadoPuerta = 0 sonido_cierra.play() vizact.onkeydown("z",cierraPuerta) I am sure that my problem is the "clickIzquierdo" section and the use of IF and ELSE... It´s my first time with the program and I still don't know so much (I have worked with C# and C++ and the logic is the same but... the way of writing it is different and thats my problem... I think). Thank you for your attention =D |
#2
|
|||
|
|||
your code seems correct. language vizard uses is python you can work with that like c#
define classes will make things clearer most of the time. class something(object): also you could use if a == 'a' and b == 'b': and elif instead of else: if: I replaced your door opening code with a print print "print this string" and I got the correct results so maybe check if your tabs are placed correctly for all the if statements. |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mouse bug in V3 and V4 | Renato Lima | Vizard | 2 | 05-11-2011 06:38 PM |
Mouse event: how to detect no mouse move event, how to set mouse position? | Zhi | Vizard | 3 | 04-11-2011 06:25 PM |
Warning mouse() -> Set mouse() of window | johannes2 | Vizard | 1 | 08-19-2010 02:11 PM |
Navigating an avatar using mouse position(2D) in 3D environment | james007 | Vizard | 1 | 10-16-2009 11:29 AM |