@name hexc
@inputs 
@outputs 
@persist HN Holo HoloN [Length SideX SideY OffX]
@trigger none

if (first()) {

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

}

while (holoCanCreate() & HoloN < 91) {
    HoloN++
    
    holoCreate(HoloN)
    holoModel(HoloN, "hexagon")
    holoScaleUnits(HoloN, vec(Length*2 - 1))
    holoParent(HoloN, entity())
    
    if (HoloN >= 91) {
        for (I = 1, 11) {
            if (I <= 6) {
                for (J = 1, HN) {
                    Holo++
                    holoPos(Holo, entity():toWorld(vec(J*SideX - OffX*HN, I*SideY, 0)))
                }
                HN++
                if (I == 6) { HN-- }
            }
            else {
                HN--
                for (J = HN, 1, -1) {
                    Holo++
                    holoPos(Holo, entity():toWorld(vec(J*SideX - OffX*HN, I*SideY, 0)))
                } 
            }
        }
        exit()
    }
}

interval(15)
