@name DeskSwitch
@inputs [Button Switch]:entity 
@outputs User:entity 
@persist A State 
@trigger 
interval(100)

findInSphere(entity():isWeldedTo():pos(),80)
User = find()

if (first()) {
    E = entity():isWeldedTo()
    Button:setAlpha(0)
    entity():setAlpha(0)
    
    holoCreate(1)
    holoMaterial(1,"models/props_c17/furnituredrawer002a")
    holoScale(1,vec(1,1.84,0.15))
    holoPos(1,E:pos()+vec(0.38,0,6))
    holoAng(1,E:angles())
    holoParent(1,E)
    
    Switch:setAng(ang(0,90,0))
}

Switch:setPos(holoEntity(1):pos()+vec(8,4,0.8))

R = User:aimEntity() == Button & changed(User:keyUse()) & User:keyUse()

if(changed(R) & R) {if(State == 0) {State = 1} else {State = 0}}

if(State == 1) {
    if(A < 0.38) {
        A += 0.01
        holoPos(1,holoEntity(1):pos()+vec(0,0.3,0))
    }
} else {
    if(A > 0) {
        A -= 0.01
        holoPos(1,holoEntity(1):pos()+vec(0,-0.3,0))
    }
}
