Scripting for a MOA switch in Ignition 8

Show the code you have, please.

Changed the code, got rid of the error, but it still will not change the tag values.

if event.source.controlValue == 'controlValue':
	
	if newValue == 0:
		event.source.bypass_on = False
		event.source.bypass_off = False
	elif newValue == 2:
		event.source.bypass_on = False
		event.source.bypass_off = True
	else:
		event.source.bypass_on = True
		event.source.bypass_off = False

Be sure to use if event.propertyName == 'controlValue': at the top. the propertyChange event fires for every property that changes. The if statement acts as a filter.

Try what @pturmel posted

if event.propertyName == 'controlValue':
	v = event.newValue
	event.source.bypassOn = v == 0
	event.source.bypassOff = v == 2

I think you need event in front of newValue

I changed Line 1 to if event.propertyName == 'controlValue': and it brought back the error code.

I saw what I did in the original. try:

if event.propertyName == 'controlValue':
	value = event.newValue

	if value == 0:
		event.source.bypass_on = False
		event.source.bypass_off = False
	elif value == 2:
		event.source.bypass_on = False
		event.source.bypass_off = True
	else:
		event.source.bypass_on = True
		event.source.bypass_off = False
1 Like