@name hexc3
@inputs 
@outputs 
@persist HoloN PosN String:string
@trigger none

local Length = 6
local SideY  = Length + Length/2
local SideX  = Length*1.732
local OffX   = SideX/2

local Entity = entity()

while (holoCanCreate() & HoloN < 91) {
    HoloN++
    holoCreate(HoloN)
    holoModel(HoloN, "hexagon")
    holoScaleUnits(HoloN, vec(Length*2 - 6))
    holoParent(HoloN, Entity)

    if (HoloN >= 91) {
        local FCounter = 6
        local RCounter = 1
        
        local ColorIndex  = 1
        local ColorRotate = 0
        
        local Colors = array(vec(45), vec(125), vec(200))
  
        for (I = 1, 11) {
            if (I == 6) { ColorRotate = 1 } 
            if (I >= 6) { FCounter-- } else { FCounter++ }
        
            ColorIndex = select(RCounter, ColorRotate ? 2 : 3, ColorRotate ? 3 : 1, 1)
            
            for (J = 1, FCounter - 1) {
                PosN++
                holoPos(PosN, Entity:toWorld(vec(FCounter*SideX, 0, 0)))
                holoColor(PosN, Colors[ColorIndex, vector])
                
                String = String + (J + ", ")
                #0.5*This["height", number]+A*sqrt(3)/2*FieldsInRow - J*A*sqrt(3)
                
                
                
                if (ColorIndex <= 0) { ColorIndex = 2 } else { ColorIndex-- }    
            }
            
            if (RCounter >= 3) { RCounter = 1} else { RCounter++ }
        }
        
        print(String)
        
        exit()
    }
}

interval(15)
