slomo = 0.0
speed = -0.03
last_input = ""

function tick()
	local curinput = GetString("game.input.curdevice")
	if last_input ~= curinput then
		last_input = curinput
		slomo = 0
		speed = -0.03
	end
	
	
	if curinput == "mouse" then
		if InputDown('t') then
			slomo = math.min(slomo + 0.03, 1)
		else
			slomo = math.max(slomo - 0.03, 0)
		end
	else
		if InputDown('extra0') then
			speed = speed * -1
		end
		slomo = math.min(math.max(slomo + speed, 0), 1)
	end

	if slomo > 0 then
		SetTimeScale(1.0 - slomo*0.8)
	end
end

function draw()
	if slomo > 0 then
		UiFont("regular.ttf", 24)
		UiTranslate(UiWidth()-30, 30)
		UiScale(1)
		UiColor(1, 1, 1, slomo)
		UiAlign("top right")
		UiText("loc@UI_TEXT_SLOW_MOTION")
	end
end

