@name Holopad Export

@persist [Holos Clips]:table HolosSpawned HolosStep LastHolo TotalHolos
@persist E:entity


if (first() | duped())
{
    E = entity()

    function number addHolo(Pos:vector, Scale:vector, Colour:vector4, Angles:angle, Model:string, Material:string, Parent:number)
    {
        if (holoRemainingSpawns() < 1) {error("This model has too many holos to spawn! (" + TotalHolos + " holos!)"), return 0}
        
        holoCreate(LastHolo, E:toWorld(Pos), Scale, E:toWorld(Angles))
        holoModel(LastHolo, Model)
        holoMaterial(LastHolo, Material)
        holoColor(LastHolo, vec(Colour), Colour:w())

        if (Parent > 0) {holoParent(LastHolo, Parent)}
        else {holoParent(LastHolo, E)}

        local Key = LastHolo + "_"
        local I=1
        while (Clips:exists(Key + I))
        {
            holoClipEnabled(LastHolo, 1)
            local ClipArr = Clips[Key+I, array]
            holoClip(LastHolo, I, holoEntity(LastHolo):toLocal(E:toWorld(ClipArr[1, vector])), holoEntity(LastHolo):toLocalAxis(E:toWorldAxis(ClipArr[2, vector])), 0)
            I++
        }
        
        return LastHolo
    }

    ##########
    # HOLOGRAMS
    

    #[   ]#    Holos[1, array] = array(vec(-39.5869, 0.0000, 37.3219), vec(3.7030, 6.7496, 8.5298), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 0.0000), "hq_dome", "", 0)
    #[   ]#    Holos[2, array] = array(vec(-39.5870, 17.3090, 99.4050), vec(6.2210, 2.0020, 0.2500), vec4(229, 165, 192, 255), ang(-98.4230, -90.0000, 90.0000), "hq_sphere", "", 0)
    #[   ]#    Holos[3, array] = array(vec(-39.5870, 17.3090, 99.4050), vec(6.6874, 2.4628, 1.4375), vec4(255, 255, 255, 255), ang(-98.4226, -90.0000, 90.0000), "hq_dome", "", 0)
    #[   ]#    Holos[4, array] = array(vec(-23.7542, -13.1050, 68.4600), vec(1.3), vec4(0, 0, 0, 255), ang(), "hq_sphere", "", 0)
    #[   ]#    Holos[5, array] = array(vec(-39.5870, -17.3090, 99.4050), vec(6.6874, 2.4630, 1.4380), vec4(255, 255, 255, 255), ang(98.4230, -90.0000, 90.0000), "hq_dome", "", 0)
    #[   ]#    Holos[6, array] = array(vec(0.0000, 0.0000, 0.0000), vec(19.3403, 11.9044, 6.1677), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 0.0000), "hq_rcube_thick", "", 0)
    #[   ]#    Holos[7, array] = array(vec(-23.7540, 13.1050, 68.4600), vec(1.3), vec4(0, 0, 0, 255), ang(), "hq_sphere", "", 0)
    #[   ]#    Holos[8, array] = array(vec(-19.4240, 5.2350, 55.4460), vec(1.0000, 1.0000, 1.0000), vec4(0, 0, 0, 255), ang(0.0000, 90.0000, 58.2314), "hq_torus", "", 0)
    #[   ]#    Holos[9, array] = array(vec(-19.4240, -5.2353, 55.4460), vec(1.0000, 1.0000, 1.0000), vec4(0, 0, 0, 255), ang(0.0000, 90.0000, 58.2314), "hq_torus", "", 0)
    #[   ]#    Holos[10, array] = array(vec(-39.5870, -17.3090, 99.4050), vec(6.2206, 2.0020, 0.2500), vec4(229, 165, 192, 255), ang(98.4230, -90.0000, 90.0000), "hq_sphere", "", 0)
    
    ##########
    
    TotalHolos = Holos:count()
    if (0 > holoClipsAvailable()) {error("A holo has too many clips to spawn on this server! (Max is " + holoClipsAvailable() + ")")}
}


#You may place code here if it doesn't require all of the holograms to be spawned.


if (HolosSpawned)
{
    #Your code goes here if it needs all of the holograms to be spawned!
}
else
{
    while (LastHolo <= Holos:count() & holoCanCreate() & perf())
    {
        local Ar = Holos[LastHolo, array]
        addHolo(Ar[1, vector], Ar[2, vector], Ar[3, vector4], Ar[4, angle], Ar[5, string], Ar[6, string], Ar[7, number])
        LastHolo++
    }
    
    if (LastHolo > Holos:count())
    {
        Holos:clear()
        Clips:clear()
        HolosSpawned = 1
        E:setAlpha(0)
    }
}
