function init()
	motors = FindJoints("motor")
	
	dir = 0
	speed = 0.25
	accelerationTime = 5

	startbutton = FindShape("startbutton")
	reversebutton = FindShape("reversebutton")
	stopbutton = FindShape("stopbutton")
	
	SetTag(startbutton, "interact", "loc@START")
	SetTag(reversebutton, "interact", "loc@REVERSE")
	SetTag(stopbutton, "interact", "loc@EMERGENCY_STOP")
	
	buttonClick = LoadSound("clickup.ogg")
	motorSound = LoadLoop("vehicle/hydraulic-loop.ogg")
	body = FindBody("body")
end


function tick(dt)
	if GetPlayerInteractShape() == startbutton then
		if InputPressed("interact") then
			SetValue("dir", 1, "linear", accelerationTime)
			PlaySound(buttonClick,GetShapeWorldTransform(startbutton).pos)
		end
	end
	if GetPlayerInteractShape() == reversebutton then
		if InputPressed("interact") then
			SetValue("dir", -1, "linear", accelerationTime)
			PlaySound(buttonClick,GetShapeWorldTransform(reversebutton).pos)
		end
	end
	if GetPlayerInteractShape() == stopbutton then
		if InputPressed("interact") then
			dir = 0
			PlaySound(buttonClick,GetShapeWorldTransform(stopbutton).pos)
		end
	end

	if dir ~= 0 then
		PlayLoop(motorSound,GetBodyTransform(body).pos)
	end

	for i=1,#motors do
		local tagValue = 1
		if GetTagValue(motors[i], "motor") ~= "" then
			tagValue = GetTagValue(motors[i],"motor")
		end
		
		SetJointMotor(motors[i], dir*speed*tagValue)
	end
end

