@name ammuts steering wheel 6
@inputs A D Active
@outputs 
@persist Wheel
@trigger 

#vader_hater501's Holographic Steering Wheel version 1.5 Type 6
#Made by vader_hater501 and Rykun. Reset Function added by Dirt

if(Active ==1){
holoAlpha(13,255)}
else{holoAlpha(13,0)}

interval(80)
runOnChat(1)
if(first()|duped())
{
E = entity()
holoCreate(13)
holoModel(13,"models/weapons/c_arms_citizen.mdl")
holoAnim(13,3)
holoPos(13,E:pos()+ vec(0,-11,20))
holoAng(13,E:angles() + ang(30,90,0))


#HOLOGRAMS

    #Center Disc (MAIN HOLOGRAM)
        #All moving holograms are parented to this.
        holoCreate(1)
        holoPos(1,entity():pos()+entity():up()*4.5)
        holoScale(1,vec(0.25,0.25,0.25))
        holoParent(1,entity())
        holoModel(1,"hq_tube")
        holoMaterial(1,"phoenix_storms/iron_rails")
        holoColor(1,vec(70,70,70))
holoParent(13,1)
    #Center Detail
        holoCreate(2)
        holoPos(2,entity():pos()+entity():up()*6.25)
        holoScale(2,vec(0.2,0.2,0.05))
        holoParent(2,1)
        holoModel(2,"hq_torus_thick")
        holoMaterial(2,"phoenix_storms/fender_chrome")
        holoColor(2,vec(255,255,255))

    #Left Arm
        holoCreate(3)
        holoPos(3,entity():pos()+entity():up()*4)
        holoScale(3,vec(0.1,0.05,1.5))
        holoParent(3,1)
        holoAng(3,entity():toWorld(ang(0,-15,70)))
        holoClipEnabled(3,1)
        holoClip(3,vec(0,0,0),vec(0,0,1),0)
        holoMaterial(3,"phoenix_storms/metalbox")
        holoColor(3,vec(255,255,255))

    #Right Arm
        holoCreate(4)
        holoPos(4,entity():pos()+entity():up()*4)
        holoScale(4,vec(0.1,0.05,1.5))
        holoParent(4,1)
        holoAng(4,entity():toWorld(ang(0,-165,70)))
        holoClipEnabled(4,1)
        holoClip(4,vec(0,0,0),vec(0,0,1),0)
        holoMaterial(4,"phoenix_storms/metalbox")
        holoColor(4,vec(255,255,255))
        
    #Center Arm
        holoCreate(5)
        holoPos(5,entity():pos()+entity():up()*4)
        holoScale(5,vec(0.1,0.05,1.5))
        holoParent(5,1)
        holoAng(5,entity():toWorld(ang(0,90,70)))
        holoClipEnabled(5,1)
        holoClip(5,vec(0,0,0),vec(0,0,1),0)
        holoMaterial(5,"phoenix_storms/metalbox")
        holoColor(5,vec(255,255,255))

    #Outer Ring (Grip)
        holoCreate(6)
        holoPos(6,entity():pos()+entity():up()*7)
        holoScale(6,vec(1.5,1.5,1.5))
        holoParent(6,1)
        holoModel(6,"hq_torus_thin")
        holoMaterial(6,"models/props_foliage/oak_tree01")
        holoColor(6,vec(70,70,70))

    #Steering Wheel Shaft
        holoCreate(7)
        holoPos(7,entity():pos()+entity():up()*-3)
        holoScale(7,vec(0.2,0.2,1.5))
        holoParent(7,1)
        holoModel(7,"hq_cylinder")
        holoMaterial(7,"phoenix_storms/iron_rails")
        holoColor(7,vec(70,70,70))
        
    #Center Detail 2
        holoCreate(8)
        holoPos(8,entity():pos()+entity():up()*3.25)
        holoScale(8,vec(0.15,0.15,0.5))
        holoParent(8,1)
        holoModel(8,"hq_cylinder")
        holoMaterial(8,"phoenix_storms/fender_chrome")
        holoColor(8,vec(70,70,70))
        
    #Center Detail 3
        holoCreate(9)
        holoPos(9,entity():pos()+entity():up()*6)
        holoScale(9,vec(0.2,0.2,0.25))
        holoParent(9,entity())
        holoModel(9,"hqtorus")
        holoMaterial(9,"phoenix_storms/iron_rails")
        holoColor(9,vec(70,70,70))

}

#ANIMATION CODE

    #Maximum Turning Angle
        MaxAngle = 25  #Increase/decrease how many degrees it can turn in either direction

    #Turning Speed
        TurnSpeed = 7  #Higher makes it less smooth, lower is slower

    if(A){if(Wheel<MaxAngle){Wheel += (A*TurnSpeed)}}
    elseif(D){if(Wheel>-MaxAngle){Wheel += (D*-TurnSpeed)}}
    else{if(Wheel>0){Wheel += -TurnSpeed}elseif(Wheel<0){Wheel += TurnSpeed}}
    Angle=entity():toWorld(ang(0,Wheel,0))   
    holoAng(1,Angle)     

#HOLOGRAM RESETTING CODE
#Use these to reset the holograms when someone new joins the server,
#Or if a player death causes them to become drawn incorrectly

    #Chat Reset (Type "!reset" in chat to redraw the holograms)
        LastSaid=owner():lastSaid():explode(" ")
        if(chatClk(owner())&LastSaid[1,string]=="!reset")
        {reset()}

if(dupefinished()){reset()}

    #Light Input (F) Reset
        #if(Light){reset()}

    #If you wish to connect the Light input to reset the holograms,
    #uncomment the Light input and the Light Input line of code.
    #Doing this and commenting the Chat Reset code can drastically
    #lower the ops of the chip.
