--flail
--codename: the holy nutsack

function init()
	frame = FindShape("frame")
	
	trig = FindTrigger("activate")
	
	motor = FindJoint("motor")
	
	timer = 1
end

function tick(dt)
	--local broken = IsShapeBroken(hammer)
	local active = IsPointInTrigger(trig, GetPlayerTransform().pos)
	
	if active then
		timer = timer - dt
		if timer > 0 then
			if GetJointMovement(motor) < 60 then
				SetJointMotorTarget(motor, 10, 6)
			end
		elseif timer <= 0 then
			if GetJointMovement(motor) > -60 then
				SetJointMotorTarget(motor, -60, 1)
			end
		end
	else
		timer = 1
		SetJointMotorTarget(motor, -60, 3)
	end
	
	--DebugPrint(speed)
end