@name Magic Window by Dangle
@inputs 
@outputs Prop:entity
@persist Prop:entity Pressed
@trigger 

runOnTick(1)
runOnChat(1)


if(first() | duped()){
    Prop = entity():isWeldedTo()
    hint("Magic Window by Jim Dangle", 4)
    hint("This is still in the early stages of development", 4)
    hint("type /help to see the commands", 7)
    Pressed = owner():keyAttack1()
    #entity():setAlpha(0)
    }

if(chatClk(owner())){
    
    Chat = owner():lastSaid():explode(" ")
    if(Chat:string(1)=="/blinds"){
        hideChat(1)
        Prop:setMaterial("models/gibs/metalgibs/metal_gibs")
        }
    if(Chat:string(1)=="/clear"){
        hideChat(1)
        Prop:setMaterial("models/props_combine/health_charger_glass")
        }
    if(Chat:string(1)=="/aim"){
        hideChat(1)
        Toggle = 1
        }
    if(Chat:string(1)=="/shoot"){
        hideChat(1)
        Toggle = 0
        }
    if(Chat:string(1)=="/help"){
        hideChat(1)
        hint("type /blinds to darken the prop", 4)
        hint("type /clear to lighten the prop", 5)
        hint("type /aim to set the window to open while aiming", 5.5)
        hint("type /shoot to set the window to open while shooting", 6)
        }
    }
if(Toggle){
    Pressed=owner():keyAttack2()
    }
else{Pressed=owner():keyAttack1()}

if(Pressed){
    On = 1
    }
else{
    On = 0
    }
    
if(On){
    Prop:propNotSolid(1)
    }
else{
    Prop:propNotSolid(0)
}

