@name Holo Clock Hands
@outputs Hours
@persist Ent:entity TimeChange
interval(100)
runOnChat(1)

if(first()){
    Ent=entity():isWeldedTo()
    if(Ent:model()!="models/props_trainstation/trainstation_clock001.mdl"){
        hint("E2 must be spawned on the HL2 trainstation clock.",7)
        selfDestruct(), exit()
    }
    for(I=1,7){
        holoCreate(I)
        holoAng(I,Ent:toWorld(ang()))
        holoClipEnabled(I,1)
        holoColor(I,vec(255,0,0))
        holoPos(I,Ent:toWorld(vec(-1,0,0)))
    }
    #Back
    holoCreate(0)
    holoModel(0,"cplane")
    holoPos(0,Ent:toWorld(vec(-0.9,0,0)))
    holoAng(0,Ent:toWorld(ang(90,0,0)))
    holoScale(0,vec(5,5,5))
    holoParent(0,Ent)
    #Minute hand
    holoParent(1,Ent)
    holoScale(1,vec(0.05,0.15,4.2))
    holoColor(1,vec())
    holoClip(1,vec(),vec(0,0,1),0)
    #Minute red thing
    holoPos(2,Ent:toWorld(vec(-0.95,0,23)))
    holoScale(2,vec(0.05,0.075,0.3))
    holoParent(2,1)
    #Hour hand
    holoParent(3,Ent)
    holoScale(3,vec(0.05,0.21,3))
    holoColor(3,vec())
    holoClip(3,vec(),vec(0,0,1),0)
    #Hour red thing
    holoPos(4,Ent:toWorld(vec(-0.95,0,16)))
    holoScale(4,vec(0.05,0.13,0.3))
    holoParent(4,3)
    #Second hand
    holoParent(5,Ent)
    holoScale(5,vec(0.05,0.05,4.2))
    holoClip(5,vec(),vec(0,0,1),0)
    holoModel(6,"cylinder")
    holoAng(6,Ent:toWorld(ang(90,0,0)))
    holoScale(6,vec(0.3,0.3,0.1))
    holoPos(6,Ent:toWorld(vec(-1.356,0,0)))
    holoParent(6,5)
    holoScale(7,vec(0.05,0.09,1))
    holoClip(7,vec(),vec(0,0,-1),0)
    holoParent(7,5)
    #Change hands depth
    holoPos(1,Ent:toWorld(vec(-0.55,0,0)))
    holoPos(5,Ent:toWorld(vec(-0.15,0,0)))
    entity():setAlpha(0), TimeChange=0
}elseif(clk()){
    holoAng(1,Ent:toWorld(ang(0,0,-time("min")*6)))
    holoAng(3,Ent:toWorld(ang(0,0,-time("hour")*30-TimeChange*30-time("min")*6/12)))
    holoAng(5,Ent:toWorld(ang(0,0,-time("sec")*6)))
    Hours=time("hour")
}elseif(chatClk(owner())){
    Said=owner():lastSaid()
    if(Said:left(2)=="!t"){
        TimeChange=Said:sub(3):toNumber()
    }
}elseif(duped()){
    reset()
}
