function init()
    door = FindShape("whyisntitworking")
    motor = FindJoint("motor_slide")
    trigger = FindTrigger("open")
    pos = GetTriggerTransform(trigger).pos
    open = false
    doors = LoadSound("doors.ogg")
    eps = 0.2
    timer = 0
end

function tick()
	LockDoors = GetBool("level.lockdoors")
	CallPointPressed = GetBool("level.firealarm.callpoint")
	isFireActive = GetBool("level.firealarm")
	reset = GetBool("level.firealarm_reset")
	FireDoor = GetBool("level.firealarm_door")
	
    if not IsHandleValid(door) or IsShapeBroken(door) or LockDoors then return end
    local p = GetPlayerPos()
    timer = timer + GetTimeStep()
    if IsPointInTrigger(trigger, p) or CallPointPressed or isFireActive or FireDoor then
        if timer < 10 then
            SetJointMotor(motor, -3)
        end
        if not open then
            PlaySound(doors,triggerPos )
            timer = 0
        end
        open = true
    else
        if timer < 10 then
            SetJointMotor(motor, 1)
        end
        if open then
            PlaySound(doors,triggerPos )
            timer = 0
        end
        open = false
    end
	
	if LockDoors and IsShapeBroken(door) then
		SetBool("level.thiefalarm", true)
	end
	
end