@name Chess Color Device
@inputs 
@outputs [Color1 Color2]:vector
@persist Int C
@trigger 
findInSphere(entity():pos(),10000)
findIncludeModel("chess")
Pieces=findToArray()
if(Int>500){Int=0}
Int+=8

if(C>Pieces:count()){C=1}
Color1=vec(0,0,floor(abs(cos(Int)*255)))
Color2=vec(floor(abs(sin(Int)*255)),0,0)

while(C>=Pieces:count()){
    Piece=Pieces[C,entity]
    if(Pieces[C,entity]:model():find("black")){
        Piece:setMaterial("models/shiny")
        #Piece:setColor(vec(0,255,0))
        Piece:setColor(Color2)
    }
    if(Pieces[C,entity]:model():find("white")){
        #Piece:setColor(vec(0,0,0))
        Piece:setColor(Color1)
        Piece:setMaterial("models/shiny")
    }
}
interval(50)
#selfDestruct()
