@name Bookcase
@inputs Prop:entity 
@outputs User:entity 
@persist 
@trigger 
#runOnTick(1)
interval(100)

findByClass("Player")
User=findClosest(Prop:pos())
E=entity():isWeldedTo()
Use=User:aimEntity() == Prop & User:keyUse()
Disance=10

if (changed(Use) & Use) {
    E:setPos(E:pos()+vec(0,-Disance,0))
    Prop:setPos(Prop:pos()+vec(0,-Disance,0))
    timer("left",250)
}

if (clk("left")) {
    E:setPos(E:pos()+vec(45,0,0))
    Prop:setPos(Prop:pos()+vec(45,0,0))
    timer("right",4000)
}

if (clk("right")) {
    E:setPos(E:pos()+vec(-45,0,0))
    Prop:setPos(Prop:pos()+vec(-45,0,0))
    timer("close",250)
}

if (clk("close")) {
    E:setPos(E:pos()+vec(0,Disance,0))
    Prop:setPos(Prop:pos()+vec(0,Disance,0))
}
