@name Danking's Holocreator
@persist Index HI ID:table

# Danking's Holocreator
#
# Hello! 
# I made this to learn arrays, tables,
# the new E2 holograms and to get better
# with strings. My goal has been met, so
# I'm releasing this so you can enjoy this
# as much as i have.
# Danking (STEAM_0:0:11688912)
#
# Syntax:
# I = Index (can be anything)
# T = Model
# N = Number
# S = String
#
# Example: -create charlie hqtorus
# Commands are not case sensitive
#
# Create a holo:        -create I T (creates a holo where you look)
# Change model of holo: -model  I T
# Move a holo:          -move   I N N N (X,Y,Z, relative to itself)
# Scale a holo:         -scale  I N N N (X,Y,Z)
# Rotate a holo:        -setrot I N N N (Pitch,Yaw,Roll)
# Color a holo:         -color  I N N N (Red,Green,Blue)
# Set alpha of holo:    -alpha  I N
# Set skin of holo:     -skin   I N
# Set material of holo: -setmat I S (S is materialpath)
# Change holo renderFX: -holofx I N
# Make holo play sound: -splay  I S (S is soundpath)
# Stop holo play sound: -sstop  I
# Stop all holo sound:  -spurge
# Remove a holo:        -remove I
# Remove all holos:     -clean
# Show holo indexes:    -index (Bugged)

runOnChat(1)

if(first())
{
    Index = 1
}

if(chatClk(owner())){
    
    #Makes stuff cleaner
    LS = lastSpoke():owner():lastSaid():lower()  #LS: LastSaid
    AR = LS:explode(" ")                         #AR: Array
    HI = ID[AR[2,string],normal]                 #HI: HoloIndex
    HN = AR[2,string]                            #HN: HoloName
    HS = AR[3,string]                            #HS: HoloString
    HE = holoEntity(HI)                          #HE: HoloEntity
    HX = AR[3,string]:toNumber()                 #HX: HoloX
    HY = AR[4,string]:toNumber()                 #HY: HoloY
    HZ = AR[5,string]:toNumber()                 #HZ: HoloZ
    HV = vec(HX,HY,HZ)                           #HV: HoloVector
    HA = ang(HV)                                 #HA: HoloAngle
    
    #Creats a holo
    if(LS:sub(1,7):find("-create")){
        hideChat(1)        
        holoCreate(Index,owner():aimPos())
        holoModel(Index,HS)
        holoAng(Index,ang(0,0,0))
        ID[AR[2,string],normal]=Index
        print("Holo '"+HN+"' with model '"+HS+"' has been created!")
        Index++
    }

    #Change model of holo
    if(LS:sub(1,6):find("-model")){
        hideChat(1)
        holoModel(HI,HS)
        print("Changed model of holo '"+HN+"' to '"+HS+"'!")
    }

    #Moves a holo
    if(LS:sub(1,5):find("-move")){
        hideChat(1)
        holoPos(HI,HE:pos()+HV)
        print("Moved holo '"+HN+"' with "+HX+"X "+HY+"Y "+HZ+"Z!")
    }

    #Scales a holo
    if(LS:sub(1,6):find("-scale")){
        hideChat(1)
        holoScale(HI,HV)
        print("Scaled holo '"+HN+"' to "+HX+"X "+HY+"Y "+HZ+"Z!")
    }
    
    #Rotates a holo
    if(LS:sub(1,7):find("-setrot")){
        hideChat(1)
        holoAng(HI,HA)
        print("Rotated holo '"+HN+"' to "+HX+"Pitch "+HY+"Yaw "+HZ+"Roll!")
    }
    
    #Colors a holo
    if(LS:sub(1,6):find("-color")){
        hideChat(1)
        holoColor(HI,HV)
        print("Colored holo '"+HN+"' to "+HX+"Red "+HY+"Green "+HZ+"Blue!")
    }
    
    #Sets alpha of holo
    if(LS:sub(1,6):find("-alpha")){
        hideChat(1)
        holoAlpha(HI,HX)
        print("Set alpha of holo '"+HN+"' to "+HX+"!")
    }
    
    #Set skin of holo
    if(LS:sub(1,5):find("-skin")){
        hideChat(1)
        holoSkin(HI,HX)
        print("Set skin of holo '"+HN+"' to '"+HS+"'!")
    }
    
    #Set material of holo
    if(LS:sub(1,7):find("-setmat")){
        hideChat(1)
        holoMaterial(HI,HS)
        print("Set material of holo '"+HN+"' to '"+HS+"'!")
    }
    
    #Change holo renderFX
    if(LS:sub(1,7):find("-holofx")){
        hideChat(1)
        holoRenderFX(HI,HX)
        print("Set renderFX of holo '"+HN+"' to '"+HS+"'!")
    }
    
    #Make holo play sound
    if(LS:sub(1,6):find("-splay")){
        hideChat(1)
        HE:soundPlay(HI,0,HS)
        print("Made holo '"+HN+"' play sound '"+HS+"'!")
    }
    
    #Make holo stop sound
    if(LS:sub(1,6):find("-sstop")){
        hideChat(1)
        soundStop(HI)
        print("Stopped sound of holo '"+HN+"'!")
    }
    
    #Stop all holo sound
    if(LS == ("-spurge")){
        hideChat(1)
        soundPurge()
        print("Stopped sound of all holos!")
    }
    
    #Removes a holo
    if(LS:sub(1,7):find("-remove")){
        hideChat(1)
        holoDelete(HI)
        print("Deleted holo '"+HN+"'!")
    }
    
    #Removes all holos and resets tables
    if(LS == "-clean"){
        hideChat(1)
        holoDeleteAll()
        ID = table()
        Index = 1
        print("Cleaned up holos!")
    }
    
    #Display indexes
    if(LS == "-index"){
        hideChat(1)
        printTable(ID)
    }
}

