@name Master Controller
@inputs Ta:entity Tb:entity Tc:entity Td:entity On
@inputs T1:wirelink T2:wirelink T3:wirelink T4:wirelink  
@outputs New1 New2 New3 New4
@persist X1 X2 X3 X4 Y1 Y2 Y3 Y4 Z1 Z2 Z3 Z4 
interval(50)
T1Hi = Ta:height()
T2Hi = Tb:height()
T3Hi = Tc:height()
T4Hi = Td:height()

T1H = Ta:health()
T2H = Tb:health()
T3H = Tc:health()
T4H = Td:health()

if (T1H==0 & Ta:isPlayer()) {New1 = 1} else {New1 = 0}
if (T2H==0 & Tb:isPlayer()) {New2 = 1} else {New2 = 0}
if (T3H==0 & Tc:isPlayer()) {New3 = 1} else {New3 = 0}
if (T4H==0 & Td:isPlayer()) {New4 = 1} else {New4 = 0}


XYZ1 = Ta:pos()
XYZ2 = Tb:pos()
XYZ3 = Tc:pos()
XYZ4 = Td:pos()
X1 = XYZ1:x()
X2 = XYZ2:x()
X3 = XYZ3:x()
X4 = XYZ4:x()

Y1 = XYZ1:y()
Y2 = XYZ2:y()
Y3 = XYZ3:y()
Y4 = XYZ4:y()

Mod = 1/2

Z1 = XYZ1:z() + (T1Hi * Mod)
Z2 = XYZ2:z() + (T2Hi * Mod)
Z3 = XYZ3:z() + (T3Hi * Mod)
Z4 = XYZ4:z() + (T4Hi * Mod)



T1:setNumber("1",X1)
T1:setNumber("2",Y1)
T1:setNumber("3",Z1)
T1:setNumber("4",On)
T1:setNumber("Channel",-201)

T2:setNumber("1",X2)
T2:setNumber("2",Y2)
T2:setNumber("3",Z2)
T2:setNumber("4",On)
T2:setNumber("Channel",-202)

T3:setNumber("1",X3)
T3:setNumber("2",Y3)
T3:setNumber("3",Z3)
T3:setNumber("4",On)
T3:setNumber("Channel",-203)

T4:setNumber("1",X4)
T4:setNumber("2",Y4)
T4:setNumber("3",Z4)
T4:setNumber("4",On)
T4:setNumber("Channel",-204)
