Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if realManualTransmission.automaticMode then -- simple quick and dirty automatic shifting.. for lazy players.
- local rpm = math.max(self.realSoundEngineRevFx*self.realEngine.ratedRpm, 500) -- get current rpm
- local kmh = self.realDisplaySpeed*3.6; -- get current km/h
- local rpmShiftPercentage = 1; -- value that determines how much load is actually on the engine to increase/decrease shifting rpm values
- rpmShiftPercentage = rpmShiftPercentage + self.realMotorLoad+self.realMotorLoadS; -- max. 3 now
- local range = self.realEngine.ratedRpm - self.realEngine.idleRpm;
- range = range/8; -- for simplicity we use only one range value that is kinda fitting for all situations..
- if rpm > ((self.realEngine.ratedRpm -range)+(range/2)*rpmShiftPercentage) and not self.timeBetweenShiftsCntDown then
- -- shift up
- self:setClutchState(true);
- self:setGear(math.min(self.td.curGear+1,self.td.maxGear));
- self:engageClutchTimeBySpeed(kmh); -- we want the time to let the clutch engage determined by the actual difference in current speed to wanted speed
- self.timeBetweenShiftsCntDown = true;
- elseif rpm < ((self.realEngine.idleRpm +range*1.4)+(range*rpmShiftPercentage)) and not self.timeBetweenShiftsCntDown then
- -- shift down
- self:setClutchState(true);
- local minG = 0;
- if rpmShiftPercentage > 1.2 then -- only allow to shift in neutral if engine is under no load
- minG = 1; -- prevents automatic from shifting into neutral if rpm goes down below threshold in 1. Gear
- end;
- self:setGear(math.max(self.td.curGear-1, minG));
- self:engageClutchTimeBySpeed(kmh);
- self.timeBetweenShiftsCntDown = true;
- end;
- if self.timeBetweenShiftsCntDown then -- count to certain time before next shift action occurs.. (simple dirty way of preventing constantly down/up shifting)
- self.timeBetweenShiftsCnt = self.timeBetweenShiftsCnt +dt;
- if self.timeBetweenShiftsCnt >= self.timeBetweenShifts then
- self.timeBetweenShiftsCntDown = false;
- self.timeBetweenShiftsCnt = 0;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement