--flail
--codename: the holy nutsack

function init()
	post = FindShape("post")
	
	motor = FindJoint("motor")
end

function tick(dt)
	local broken = IsShapeBroken(post)
	local speed = GetFloat("flail.speed")
	
	if not broken then
		SetFloat("flail.speed", 45.0)
	else
		SetFloat("flail.speed", speed - (dt*20))
		if speed <= 0 then
			SetFloat("flail.speed", 0)
		end
	end

	SetJointMotor(motor, speed)
	
	--DebugPrint(speed)
end