local M = {}
local CCtarget = 0

local function increaseCCSpeed()
	extensions.use('cruiseControl').changeSpeed( 10/3.6)
	CCtarget = math.floor(electrics.values.cruiseControlTarget * 3.6)
	guihooks.message("Cruise Control speed increased to " .. CCtarget .. "km/h", 4, "vehicle.vertexCC.CCspeed", "menu")
end

local function decreaseCCSpeed()
	extensions.use('cruiseControl').changeSpeed(-10/3.6)
	CCtarget = math.floor(electrics.values.cruiseControlTarget * 3.6)
	guihooks.message("Cruise Control speed decreased to " .. CCtarget .. "km/h", 4, "vehicle.vertexCC.CCspeed", "menu")
end

local function toggleCC()
	if electrics.values.cruiseControlActive == 0 then
		extensions.use('cruiseControl').setEnabled(true)
		guihooks.message("Cruise Control Enabled", 4, "vehicle.vertexCC.CCtoggle", "menu")
	else
		extensions.use('cruiseControl').setEnabled(false)
		guihooks.message("Cruise Control Disabled", 4, "vehicle.vertexCC.CCtoggle", "menu")
	end
end

M.increaseCCSpeed = increaseCCSpeed
M.decreaseCCSpeed = decreaseCCSpeed
M.toggleCC = toggleCC

return M
