@name SpeedoKit1
@inputs KPH MPH RPM Gear Scr:wirelink 
@outputs MPH 
@model models/sprops/rectangles_thin/size_1/rect_3x3x1_5.mdl
interval(100)

MPH = toUnit("mph",entity():vel():length())

if(first()|dupefinished()){
    E=entity()
    E:setAlpha(0)
    
    #Face Color
    R=0
    G=0
    B=0  
    #Needle Color
    NeedleR=0
    NeedleG=50
    NeedleB=255
    
    Red= vec(255,0,0)
    Green= vec(0,255,0)
    Blue= vec(0,0,255)
    Alpha= vec4(0,0,0,0)
    
    HoloC = 5,6
    
        #255,75,0 - Orange
        #0,255,0 - Green
        #0,255,255 - Cyan Blue
    
    #Set Width Apart
    Gap=5.5
    SpeedGap=-Gap
        
    #Set Scale of Gauges
    Scale=0.4
}

if(first()|dupefinished()){
#---------- SPEED
    
    #Index, Position, Scale, Angle, Color (RGB)
    
    #Speedo Gauge
    holoCreate(1,E:toWorld(vec(Scale*0,Scale*SpeedGap,Scale*-2)),vec(Scale*1,Scale*1,Scale*1),E:toWorld(ang(-90,0,0)),vec(R,G,B))
    holoModel(1,"models/sprops/trans/misc/gauge_3.mdl")
    holoParent(1,E)
    holoSkin(1,0)

    #Needle Disk
    holoCreate(2,E:toWorld(vec(Scale*0,Scale*SpeedGap,Scale*-1.1)),vec(Scale*0.05,Scale*0.2,Scale*0.05),E:toWorld(ang(0,0,90)),vec(NeedleR,NeedleG,NeedleB))
    holoModel(2,"models/sprops/geometry/t_fdisc_12.mdl")
    holoMaterial(2,"sprops/textures/sprops_metal5")
    holoParent(2,E)
    
    #Needle
    holoCreate(3,E:toWorld(vec(Scale*2,Scale*SpeedGap,Scale*-1.1)),vec(Scale*0.1,Scale*0.1,Scale*0.625),E:toWorld(ang(0,90,90)),vec(NeedleR,NeedleG,NeedleB))
    holoModel(3,"models/sprops/triangles/misc/ctri_6.mdl")
    holoMaterial(3,"sprops/textures/sprops_metal5") 
    holoParent(3,holoEntity(2))

#---------- TACH
 
    #Tachometer 
    holoCreate(4,E:toWorld(vec(Scale*0,Scale*Gap,Scale*-2)),vec(Scale*1,Scale*1,Scale*1),E:toWorld(ang(-90,0,0)),vec(R,G,B))
    holoModel(4,"models/sprops/trans/misc/gauge_3.mdl")
    holoParent(4,E)
    holoSkin(4,1)

    #Needle Disk
    holoCreate(5,E:toWorld(vec(Scale*0,Scale*Gap,Scale*-1.1)),vec(Scale*0.05,Scale*0.05,Scale*0.05),E:toWorld(ang(0,0,90)),vec(NeedleR,NeedleG,NeedleB))
    holoModel(5,"models/sprops/geometry/t_fdisc_12.mdl")
    holoMaterial(5,"sprops/textures/sprops_metal5")
    holoParent(5,E)
    
    #Needle
    holoCreate(6,E:toWorld(vec(Scale*2,Scale*Gap,Scale*-1.1)),vec(Scale*0.1,Scale*0.1,Scale*0.625),E:toWorld(ang(0,90,90)),vec(NeedleR,NeedleG,NeedleB))
    holoModel(6,"models/sprops/triangles/misc/ctri_6.mdl")
    holoMaterial(6,"sprops/textures/sprops_metal5") 
    holoParent(6,holoEntity(5)) 
    
    #Index, Position, Scale, Angle, Color (RGB)    

####Text on Indicator's
    
# 1
    holoCreate(10, E:toWorld(vec(Scale*-4.5,Scale*0,Scale*3.5)), vec(Scale*0.25,Scale*0.25,Scale*0.25), E:toWorld(ang(0,-90,90)))
    holoModel(10, "models/sprops/misc/alphanum/alphanum_1.mdl")
    holoMaterial(10, "sprops/textures/sprops_metal5")
    holoParent(10, E)
    holoColor(10, Red)
# 2
    holoCreate(11, E:toWorld(vec(Scale*-4.6,Scale*0,Scale*3.5)), vec(Scale*0.25,Scale*0.25,Scale*0.25), E:toWorld(ang(0,-90,90)))
    holoModel(11, "models/sprops/misc/alphanum/alphanum_2.mdl")
    holoMaterial(11, "sprops/textures/sprops_metal5")
    holoParent(11, E)
    holoColor(11, Red)
# 3
    holoCreate(12, E:toWorld(vec(Scale*-4.6,Scale*0,Scale*3.5)), vec(Scale*0.25,Scale*0.25,Scale*0.25), E:toWorld(ang(0,-90,90)))
    holoModel(12, "models/sprops/misc/alphanum/alphanum_3.mdl")
    holoMaterial(12, "sprops/textures/sprops_metal5")
    holoParent(12, E)
    holoColor(12, Red)
# 4
    holoCreate(13, E:toWorld(vec(Scale*-4.6,Scale*0,Scale*3.5)), vec(Scale*0.25,Scale*0.25,Scale*0.25), E:toWorld(ang(0,-90,90)))
    holoModel(13, "models/sprops/misc/alphanum/alphanum_4.mdl")
    holoMaterial(13, "sprops/textures/sprops_metal5")
    holoParent(13, E)
    holoColor(13, Red)
# 5
    holoCreate(14, E:toWorld(vec(Scale*-4.6,Scale*0,Scale*3.5)), vec(Scale*0.25,Scale*0.25,Scale*0.25), E:toWorld(ang(0,-90,90)))
    holoModel(14, "models/sprops/misc/alphanum/alphanum_5.mdl")
    holoMaterial(14, "sprops/textures/sprops_metal5")
    holoParent(14, E)
    holoColor(14, Red)
    
    # R
    holoCreate(9, E:toWorld(vec(Scale*-4.6,Scale*0.2,Scale*3.5)), vec(Scale*0.25,Scale*0.25,Scale*0.25), E:toWorld(ang(0,-90,90)))
    holoModel(9, "models/sprops/misc/alphanum/alphanum_r.mdl")
    holoMaterial(9, "sprops/textures/sprops_metal5")
    holoParent(9, E)
    holoColor(9, Blue)
}    
    
if(Gear == 1) { holoAlpha(10, 255) } else { holoAlpha(10, 0) }
if(Gear == 2) { holoAlpha(11, 255) } else { holoAlpha(11, 0) }
if(Gear == 3) { holoAlpha(12, 255) } else { holoAlpha(12, 0) }
if(Gear == 4) { holoAlpha(13, 255) } else { holoAlpha(13, 0) }
if(Gear == 5) { holoAlpha(14, 255) } else { holoAlpha(14, 0) }
if(Gear == 6) { holoAlpha(9, 255) } else { holoAlpha(9, 0) }

#### Math ####

RPM_Max = 4000
RPM_Ang = ((RPM/RPM_Max)*-320)
Redline = 4000


if (RPM >= Redline) { holoColor(16, vec(255, 0, 0)) } else {holoColor(16, vec(100,0,0))}

    #MPH Code AKA: THE SEIKI DARK MAGIK
holoAng(2,entity():toWorld(ang(0,MPH*-1.78,90)))

    #KPH Code -- Must Enable for KPH!
#holoAng(2,entity():toWorld(ang(0,KPH*-1.78,90)))

    #RPM Code AKA: OUTLAWS DARK MAGIK
holoAng(5,entity():toWorld(ang(0,RPM_Ang,90)))
if (first()) {
    Scr:egpClear()
    Scr:egpText(1, "000", vec2(256, 463))
    Scr:egpColor(1,vec(0,0,0))
    Scr:egpSize(1,20)
    Scr:egpFont(1, "ChatFont")
    Scr:egpAlign(1, 1)
}
Scr:egpSetText(1, "" + MPH)

