function init()
	motor = FindJoint("motor")	
	min, max = GetJointLimits(motor)
	target = 0
	speed = 0

	startbutton = FindShape("startbutton")
	dropbutton = FindShape("dropbutton")
	stopbutton = FindShape("stopbutton")
	
	SetTag(startbutton, "interact", "Òöãôö")
	SetTag(dropbutton, "interact", "Âñìë")
	SetTag(stopbutton, "interact", "Àåãôìíñºí õöòó")	
	
	buttonClick = LoadSound("clickup.ogg")
	motorSound = LoadLoop("vehicle/hydraulic-loop.ogg")
	oldMotorPos = GetJointMovement(motor)
	body = FindBody("body")
end


function tick(dt)
	local current = GetJointMovement(motor)
	if GetPlayerInteractShape() == startbutton then
		if InputPressed("interact") then
			target = max
			speed = 1
			PlaySound(buttonClick,GetShapeWorldTransform(startbutton).pos)
		end
	end
	if GetPlayerInteractShape() == dropbutton then
		if InputPressed("interact") then
			target = min
			speed = 10
			PlaySound(buttonClick,GetShapeWorldTransform(dropbutton).pos)
		end
	end
	if GetPlayerInteractShape() == stopbutton then
		if InputPressed("interact") then
			target = current
			speed = 0
			PlaySound(buttonClick,GetShapeWorldTransform(stopbutton).pos)
		end
	end

	if GetJointMovement(motor) - oldMotorPos > 0.01 then
		PlayLoop(motorSound,GetBodyTransform(body).pos)
	end

	oldMotorPos = GetJointMovement(motor)
	SetJointMotorTarget(motor, target, speed)	
end

