local l={}local E={}local O={}local u={}for I,J in pairs(_Tune.Ratios)do local q={}local c={}local n={}local x={}for l=0,math.ceil((_Tune.Redline+100)/100),1 do local E={}local O={}local u={}local J={}if l~=0 then if _Tune.Engine then E.Horsepower,E.Torque=GetNCurve(l*100,I-2)if _TCount~=0 then u.Horsepower,u.Torque=GetTCurve(l*100,I-2)else u.Horsepower,u.Torque=0,0 end if _SCount~=0 then J.Horsepower,J.Torque=GetSCurve(l*100,I-2)else J.Horsepower,J.Torque=0,0 end else E.Horsepower,E.Torque=0,0 u.Horsepower,u.Torque=0,0 J.Horsepower,J.Torque=0,0 end if _Tune.Electric then O.Horsepower,O.Torque=GetECurve(l*100,I-2)else O.Horsepower,O.Torque=0,0 end else E.Horsepower,E.Torque=0,0 O.Horsepower,O.Torque=0,0 u.Horsepower,u.Torque=0,0 J.Horsepower,J.Torque=0,0 end if _Tune.Engine then nhp,ntq=GetNCurve((l+1)*100,I-2)if _TCount~=0 then thp,ttq=GetTCurve((l+1)*100,I-2)else thp,ttq=0,0 end if _SCount~=0 then shp,stq=GetSCurve((l+1)*100,I-2)else shp,stq=0,0 end else nhp,ntq=0,0 thp,ttq=0,0 shp,stq=0,0 end if _Tune.Electric then ehp,etq=GetECurve((l+1)*100,I-2)else ehp,etq=0,0 end E.HpSlope,E.TqSlope=nhp-E.Horsepower,ntq-E.Torque O.HpSlope,O.TqSlope=ehp-O.Horsepower,etq-O.Torque u.HpSlope,u.TqSlope=thp-u.Horsepower,ttq-u.Torque J.HpSlope,J.TqSlope=shp-J.Horsepower,stq-J.Torque q[l]=E c[l]=O n[l]=u x[l]=J end table.insert(l,q)table.insert(E,c)table.insert(O,n)table.insert(u,x)end

local NCache = {}
local ECache = {}
local TCache = {}
local SCache = {}

for gear,ratio in pairs(_Tune.Ratios) do
	local nhpPlot = {}
	local ehpPlot = {}
	local thpPlot = {}
	local shpPlot = {}
	for rpm = 0, math.ceil((_Tune.Redline+100)/100) do
		local ntqPlot = {}
		local etqPlot = {}
		local ttqPlot = {}
		local stqPlot = {}
		if rpm~=0 then
			if _Tune.Engine then
				ntqPlot.Horsepower,ntqPlot.Torque = GetNCurve(rpm*100,gear-2)
				if _TCount~=0 then
					ttqPlot.Horsepower,ttqPlot.Torque = GetTCurve(rpm*100,gear-2)
				else
					ttqPlot.Horsepower,ttqPlot.Torque = 0,0
				end
				if _SCount~=0 then
					stqPlot.Horsepower,stqPlot.Torque = GetSCurve(rpm*100,gear-2)
				else
					stqPlot.Horsepower,stqPlot.Torque = 0,0
				end
			else
				ntqPlot.Horsepower,ntqPlot.Torque = 0,0
				ttqPlot.Horsepower,ttqPlot.Torque = 0,0
				stqPlot.Horsepower,stqPlot.Torque = 0,0
			end
			if _Tune.Electric then
				etqPlot.Horsepower,etqPlot.Torque = GetECurve(rpm*100,gear-2)
			else
				etqPlot.Horsepower,etqPlot.Torque = 0,0
			end
		else
			ntqPlot.Horsepower,ntqPlot.Torque = 0,0
			etqPlot.Horsepower,etqPlot.Torque = 0,0
			ttqPlot.Horsepower,ttqPlot.Torque = 0,0
			stqPlot.Horsepower,stqPlot.Torque = 0,0
		end
		if _Tune.Engine then
			nhp,ntq = GetNCurve((rpm+1)*100,gear-2)
			if _TCount~=0 then
				thp,ttq = GetTCurve((rpm+1)*100,gear-2)
			else
				thp,ttq = 0,0
			end
			if _SCount~=0 then
				shp,stq = GetSCurve((rpm+1)*100,gear-2)
			else
				shp,stq = 0,0
			end
		else
			nhp,ntq = 0,0
			thp,ttq = 0,0
			shp,stq = 0,0
		end
		if _Tune.Electric then
			ehp,etq = GetECurve((rpm+1)*100,gear-2)
		else
			ehp,etq = 0,0
		end
		ntqPlot.HpSlope,ntqPlot.TqSlope = (nhp-ntqPlot.Horsepower),(ntq-ntqPlot.Torque)
		etqPlot.HpSlope,etqPlot.TqSlope = (ehp-etqPlot.Horsepower),(etq-etqPlot.Torque)
		ttqPlot.HpSlope,ttqPlot.TqSlope = (thp-ttqPlot.Horsepower),(ttq-ttqPlot.Torque)
		stqPlot.HpSlope,stqPlot.TqSlope = (shp-stqPlot.Horsepower),(stq-stqPlot.Torque)
		nhpPlot[rpm] = ntqPlot
		ehpPlot[rpm] = etqPlot
		thpPlot[rpm] = ttqPlot
		shpPlot[rpm] = stqPlot
	end
	table.insert(NCache,nhpPlot)
	table.insert(ECache,ehpPlot)
	table.insert(TCache,thpPlot)
	table.insert(SCache,shpPlot)
end
