In this example, we will see see how to work with the values of multiple controls wired to the inputs on the Live Python block.
By default, a Live Python block is configured to monitor all the inputs, and run the Python code inside the block as soon as an input value changes. This is the behavior that we want for this example, so we will leave the property (watch input) set to any on the device properties.
To set up a Live Python block with multiple input devices
total=0
average=0
for x in range(len(inputs)):
total += inputs[x].value_get()
average=round(total/len(inputs),3)
message.string_set("The average of the input values is " + str( average ))
The message on the control surface of the Live Python block will show the average of the knob values.
See also Building a simple Python example in NWare |