Hi,
Yes you can add boolean signals:
After having added the script you have to connect the signals with it:
Here is an example of a script that might help you:
from vcScript import *
def OnSignal( signal ):
print "A signal was received"
if signal == signal_green and signal_green.Value == True:
#switch off other signals
signal_yellow.Value = False
signal_red.Value = False
#set properties
light_green.Value = True
light_yellow.Value = False
light_red.Value = False
print "Light changed to green."
print "State of the signals: \t","green=",signal_green.Value, "\tyellow=",signal_yellow.Value, "\tred=", signal_red.Value
elif signal == signal_yellow and signal_yellow.Value == True:
#switch off other signals
signal_green.Value = False
signal_red.Value = False
#set properties
light_green.Value = False
light_yellow.Value = True
light_red.Value = False
print "Light changed to yellow."
print "State of the signals: \t","green=",signal_green.Value, "\tyellow=",signal_yellow.Value, "\tred=", signal_red.Value
elif signal == signal_red and signal_red.Value == True:
#switch off other signals
signal_green.Value = False
signal_yellow.Value = False
#set properties
light_green.Value = False
light_yellow.Value = False
light_red.Value = True
print "Light changed to red."
print "State of the signals: \t","green=",signal_green.Value, "\tyellow=",signal_yellow.Value, "\tred=", signal_red.Value
if signal == signal_green and signal_green.Value == False:
#reset property
light_green.Value = False
print "Green light is switched off."
print "State of the signals: \t","green=",signal_green.Value, "\tyellow=",signal_yellow.Value, "\tred=", signal_red.Value
elif signal == signal_yellow and signal_yellow.Value == False:
#reset property
light_yellow.Value = False
print "Yellow light is switched off."
print "State of the signals: \t","green=",signal_green.Value, "\tyellow=",signal_yellow.Value, "\tred=", signal_red.Value
elif signal == signal_red and signal_red.Value == False:
#reset property
light_red.Value = False
print "Red light is switched off."
print "State of the signals: \t","green=",signal_green.Value, "\tyellow=",signal_yellow.Value, "\tred=", signal_red.Value
def OnRun():
pass
comp = getComponent()
signal_green = comp.getBehaviour("Green")
signal_yellow = comp.getBehaviour("Yellow")
signal_red = comp.getBehaviour("Red")
light_green = comp.getProperty("Green")
light_yellow = comp.getProperty("Yellow")
light_red = comp.getProperty("Red")
There are different ways how to use signals. Here you can learn more about it:
Have a nice day.