(Conveyor) sensor detect can script

Hi,

Is it possible to detect the can with this sensor? If so, how can i get the sensor signal into a script? the script belongs to an external servo and not by the sensor.

Let me know!

Sure! Firstly, the sensor component that comes with VC it’s essentially a ray sensor, which means that it can certainly detect your canister. Secondly, about what you said about connecting the signal inside the script, because it’s not in the same component, he really can’t connect it directly to the script to use it, one of the compromise is to create a signal in the component where the script is located when the two signals are connected and then accessed to the script, this is the best way, but practically, if there are more signals in this way, it will lead to very difficult to manipulate, for example, you may accidentally delete some of the connections without noticing. Of course, there are other ways to do this, and in your script you can use the following script to listen for the desired signal value:

from vcScript import *
app = getApplication()
sensor = app.findComponent('Conveyor Sensor')
signal = sensor.findBehaviour('SensorBooleanSignal')
def OnRun().
  while signal.Value == False.
    delay(0.1)
  print "..."

There are good things and bad things, and when there is too much while, it can be computer unfriendly, which requires a trade-off on your part.
SensorSignal.vcmx (857.8 KB)

Hi,

Thanks for the explanation and for the layout! That’s exactly what I wanted.