################
# > Holo Creator: Create holograms using chat.
# > How to use: Spawn it and read the messages it prints in chat.
################

@name Hologram Creator
@outputs R G B X Y Z AX AY AZ PX PY PZ SX SY SZ
@persist R G B X Y Z AX AY AZ PX PY PZ SX SY SZ
@persist Alpha Shadow

Cmdlist = array("credits", "create", "red", "green", "blue", "colourall", "angx", "angy", "angz", "angall", "parent", "posx", "pos", "posz", "pos", "posall", "scalex", "scaley", "scalez", "scaleall", "modellist", "model", "alpha", "shadow", "material")
Holomodels = array("cone","cube","cylinder","prism","pyramid","icosphere","icosphere2","icosphere3","sphere","sphere2","sphere3","torus","torus2","torus3","hqcone","dome","dome2","hqcylinder","hqcylinder2","hqsphere","hqsphere2","hqicosphere","hqicosphere2","hqtorus","hqtorus2","plane","tetra")
E = entity()
O = owner()
CC = (chatClk())
Cmd = (O:lastSaid():explode(" "):string(2):lower())
Val = (O:lastSaid():explode(" "):string(3):lower())

if(first()){
    printTable(Cmdlist)
    print("Thank you for using Holo Creator, created by Runeneo!")
    print("Type -holo before the command to run the chip.")
    runOnChat(1)
}

# Run Code

if ((CC)&(O:lastSaid():explode(" "):string(1):left(5) == "-holo")) {
    
Set = O:lastSaid():explode(" "):string(1):right(1):toNumber()
    
# Credits
    
    if ((CC)&(Cmd == "credits")) {
        print("Holo Creator was created by Runeneo.")
    }
    
# Create

    if ((CC)&(Cmd == "create")) {
        holoCreate(Set)
        holoScale(Set, (vec(1,1,1)))
    }

# Color

    if ((CC)&(Cmd == "red")) {
        R = Val:toNumber()
        G = G
        B = B
        holoColor(Set, (vec(R,G,B)))
    }

    if ((CC)&(Cmd == "green")) {
        R = R
        G = Val:toNumber()
        B = B
        holoColor(Set, (vec(R,G,B)))
    }
    
    if ((CC)&(Cmd == "blue")) {
        R = R
        G = G
        B = Val:toNumber()
        holoColor(Set, (vec(R,G,B)))
    }
    
    if ((CC)&(Cmd == "colourall")) {
        R = Val:toNumber()
        G = Val:toNumber()
        B = Val:toNumber()
        holoColor(Set, (vec(R,G,B)))
    }
    
# Angles

    if ((CC)&(Cmd == "angx")) {
        AX = Val:toNumber()
        AY = AY
        AZ = AZ
        holoAng(Set, (ang(AX,AY,AZ)))
    }

    if ((CC)&(Cmd == "angy")) {
        AX = AX
        AY = Val:toNumber()
        AZ = AZ
        holoAng(Set, (ang(AX,AY,AZ)))
    }
    
    if ((CC)&(Cmd == "angz")) {
        AX = AX
        AY = AY
        AZ = Val:toNumber()
        holoAng(Set, (ang(AX,AY,AZ)))
    }
    
    if ((CC)&(Cmd == "angall")) {
        AX = Val:toNumber()
        AY = Val:toNumber()
        AZ = Val:toNumber()
        holoAng(Set, (ang(AX,AY,AZ)))
    }
    
# Parent

    if ((CC)&(Cmd == "parent")) {
        if (Val == "owner") {
            holoParent(Set, owner())
        }
        
        if (Val == "entity") {
            holoParent(Set, entity())
        }
        
        if (Val == "remove") {
            holoUnparent(Set)
        }
    }

# Pos

    if ((CC)&(Cmd == "posx")) {
        PX = Val:toNumber()
        PY = PY
        PZ = PZ
        holoPos(Set, entity():toWorld(vec(PX,PY,PZ)))
    }
    
    if ((CC)&(Cmd == "posy")) {
        PX = PX
        PY = Val:toNumber()
        PZ = PZ
        holoPos(Set, entity():toWorld(vec(PX,PY,PZ)))
    }
    
    if ((CC)&(Cmd == "posz")) {
        PX = PX
        PY = PY
        PZ = Val:toNumber()
        holoPos(Set, entity():toWorld(vec(PX,PY,PZ)))
    }
    
if ((CC)&(Cmd == "pos")) {
    if (Val == "owner") {
        
        PX = PX
        PY = PY
        PZ = PZ
        holoPos(Set, owner():toWorld(vec(PX,PY,PZ)))
    }
    
    if (Val == "entity") {
        PX = PX
        PY = PY
        PZ = PZ
        holoPos(Set, entity():toWorld(vec(PX,PY,PZ)))
    }   
    
    if (Val == "aimpos") {
        PX = PX
        PY = PY
        PZ = PZ
        holoPos(Set, owner():aimPos()+vec(PX,PY,PZ))
    }         
}

    if ((CC)&(Cmd == "posall")) {
        PX = Val:toNumber()
        PY = Val:toNumber()
        PZ = Val:toNumber()
        holoPos(Set, entity():toWorld(vec(PX,PY,PZ)))
    }
    
# Scale

    if ((CC)&(Cmd == "scalex")) {
        SX = Val:toNumber()
        SY = SY
        SZ = SZ
        holoScale(Set, (vec(SX,SY,SZ)))
    }
    
    if ((CC)&(Cmd == "scaley")) {
        SX = SX
        SY = Val:toNumber()
        SZ = SZ
        holoScale(Set, (vec(SX,SY,SZ)))
    }
    
    if ((CC)&(Cmd == "scalez")) {
        SX = SX
        SY = SY
        SZ = Val:toNumber()
        holoScale(Set, (vec(SX,SY,SZ)))
    }
    
    if ((CC)&(Cmd == "scaleall")) {
        SX = Val:toNumber()
        SY = Val:toNumber()
        SZ = Val:toNumber()
        holoScale(Set, (vec(SX,SY,SZ)))
    }
    
    if (SX == 0) { SX = 1 }
    if (SY == 0) { SY = 1 }
    if (SZ == 0) { SZ = 1 }
    
# Alpha

    if ((CC)&(Cmd == "alpha")) {
        Alpha = Val:toNumber()
        holoAlpha(Set, Alpha)
    }
    
# Shadow

    if ((CC)&(Cmd == "shadow")) {
        Shadow = Val:toNumber()
        holoShadow(Set, Shadow)
    }
    
# Models

    if ((CC)&(Cmd == "modellist")) {
        printTable(Holomodels)
    }
    
    if ((CC)&(Cmd == "model")) {
        holoModel(Set, Val)
    }

# Materials

    if ((CC)&(Cmd == "material")) {
        holoMaterial(Set, Val)
    }
}
