@name Joystick
@inputs Pod:wirelink
@outputs 
@persist 
@trigger 
#runOnTick(1)
interval(200)

if (first()) {
    holoCreate(1)
    holoModel(1,"hq_dome")
    holoPos(1,entity():toWorld(vec(0,0,2)))
    holoColor(1,vec(65,65,65))
    holoScale(1,vec(0.5,0.5,0.5))
    holoParent(1,entity())
    
    holoCreate(4)
    holoModel(4,"hq_dome")
    holoPos(4,entity():toWorld(vec(0,0,2)))
    holoScale(4,vec(0.52,0.52,0.52))
    holoParent(4,entity())
    holoClipEnabled(4,1,1)
    holoClip(4,vec(0,0,1.3),vec(0,0,-1),0)
    
    holoCreate(2)
    holoModel(2,"models/sprops/misc/fittings/bend_long_90_3.mdl")
    holoPos(2,entity():toWorld(vec(0,0,8)))
    holoMaterial(2,"models/debug/debugwhite")
    holoColor(2,vec(0,0,0))
    holoAng(2,ang(25,0,0))
    holoParent(2,1)
    
    holoCreate(3)
    holoModel(3,"models/sprops/triangles/right/size_0/rtri_3x3.mdl")
    holoPos(3,entity():toWorld(vec(-1.5,0,9.6)))
    holoMaterial(3,"models/debug/debugwhite")
    holoColor(3,vec(255,0,0))
    holoAng(3,ang(70,180,0))
    holoScale(3,vec(0.5,0.5,0.5))
    holoParent(3,2)
}

local Seat = Pod["Entity",entity]
local Driver = Seat:driver()
local W = Driver:keyForward()
local A = Driver:keyLeft()
local S = Driver:keyBack()
local D = Driver:keyRight()
local Mouse1 = Driver:keyAttack1()
local Mouse2 = Driver:keyAttack2()
local Shift = Driver:keySprint()
local Active = Driver:isPlayer()

if (W) {
    holoAng(1,entity():angles()+ang(-15,0,0))
} elseif (S) {
    holoAng(1,entity():angles()+ang(15,0,0))
} elseif (A) {
    holoAng(1,entity():angles()+ang(0,0,15))
} elseif (D) {
    holoAng(1,entity():angles()+ang(0,0,-15))
} elseif (Mouse1) {
    holoAng(3,ang(90,180,0))
} else {
    holoAng(1,entity():angles())
    holoAng(3,ang(70,180,0))
}
if (W & A) {
    holoAng(1,entity():angles()+ang(-15,0,15))
} elseif (W & D) {
    holoAng(1,entity():angles()+ang(-15,0,-15))
} elseif (S & A) {
    holoAng(1,entity():angles()+ang(15,0,15))
} elseif (S & D) {
    holoAng(1,entity():angles()+ang(15,0,-15))
} elseif (Mouse1 & W & !A & !S & !D) {
    holoAng(3,ang(90,180,0))
}
