flip = GetIntParam("flip", 1)
multiply = GetIntParam("multiply", 1)
function init()
motor = FindJoint("door")
doorshape = FindShape("doorshape")



end



function tick()

local min, max = GetJointLimits(motor)

limitcheck = max - min 


--DebugWatch("high", max)
--DebugWatch("low", min) 
openamount = GetJointMovement(motor)

grabshape = GetPlayerGrabShape()
	
--DebugWatch("grabshape", grabshape)
		SetJointMotor(motor, 0,0) 
	
	if openamount > limitcheck/2 and grabshape ~= doorshape then 
		SetJointMotor(motor, -1.5* flip , 80*multiply)
	end 

	if openamount < limitcheck/2 and grabshape ~= doorshape then 
		SetJointMotor(motor, 1.5 * flip , 80*multiply)
	end 
	
	if grabshape == DoorShape then 
		SetJointMotor(motor, 0, 0) 
	end 

	--DebugWatch("Open Amount", openamount)
	--DebugWatch("joint limits", openlimits)

end 