@name Holopad Export

#####
# Holograms authored by Divalent on 02/10/2015
# Exported from Holopad 09/11/2012 (BETA 6.7) by Bubbus
# Thanks to Vercas for the original E2 export template!
#
# FOR AN EXPLANATION OF THE CODE BELOW, VISIT http://code.google.com/p/holopad/wiki/NewE2ExportFormatHOWTO
##### 

#####
# Hologram spawning data
@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(0.0000, -7.9657, 0.5783), vec(0.2000, 0.2000, 0.2000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[2, array] = array(vec(0.0000, -5.7059, 0.4794), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[3, array] = array(vec(0.0000, -2.2228, 2.4682), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[4, array] = array(vec(0.0000, 0.6729, 3.1642), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[5, array] = array(vec(0.0000, 6.4071, 2.6640), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[6, array] = array(vec(0.0000, 2.6804, 2.9680), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[7, array] = array(vec(0.0000, -4.7420, 1.1798), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[8, array] = array(vec(0.0000, 0.0000, 0.0000), vec(0.8000, 2.0000, 0.8000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 0.0000), "hq_hdome_thin", "", 0)
    #[   ]#    Holos[9, array] = array(vec(0.0000, -0.5606, 2.2681), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[10, array] = array(vec(0.0000, 4.5172, 2.7973), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[11, array] = array(vec(0.0000, 10.3715, 1.6087), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[12, array] = array(vec(0.0000, -6.3600, -0.1386), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[13, array] = array(vec(0.0000, 8.1542, 2.6239), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[14, array] = array(vec(0.0000, -3.4831, 1.7246), vec(0.3000, 0.3000, 0.3000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 0)
    #[   ]#    Holos[15, array] = array(vec(0.0000, 0.0000, 0.0000), vec(0.8000, 2.0000, 0.1906), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 180.0000), "hq_hdome_thin", "", 0)
    #[   ]#    Holos[16, array] = array(vec(0.0000, -8.2766, -0.0467), vec(0.2000, 0.2000, 0.2000), vec4(255, 255, 255, 255), ang(0.0000, 0.0000, 36.0000), "models/sprops/misc/domes/size_0/dome_3x18.mdl", "", 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)
    }

    interval(1000)
}
