daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Apr 28th, 2014 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if realManualTransmission.automaticMode then -- simple quick and dirty automatic shifting.. for lazy players.
  2.         local rpm = math.max(self.realSoundEngineRevFx*self.realEngine.ratedRpm, 500) -- get current rpm
  3.         local kmh = self.realDisplaySpeed*3.6; -- get current km/h
  4.         local rpmShiftPercentage = 1; -- value that determines how much load is actually on the engine to increase/decrease shifting rpm values
  5.         rpmShiftPercentage = rpmShiftPercentage + self.realMotorLoad+self.realMotorLoadS; -- max. 3 now
  6.         local range = self.realEngine.ratedRpm - self.realEngine.idleRpm;
  7.         range = range/8; -- for simplicity we use only one range value that is kinda fitting for all situations..
  8.         if rpm > ((self.realEngine.ratedRpm -range)+(range/2)*rpmShiftPercentage) and not self.timeBetweenShiftsCntDown then
  9.                 -- shift up
  10.                 self:setClutchState(true);
  11.                 self:setGear(math.min(self.td.curGear+1,self.td.maxGear));
  12.                 self:engageClutchTimeBySpeed(kmh); -- we want the time to let the clutch engage determined by the actual difference in current speed to wanted speed
  13.                 self.timeBetweenShiftsCntDown = true;
  14.         elseif rpm < ((self.realEngine.idleRpm +range*1.4)+(range*rpmShiftPercentage)) and not self.timeBetweenShiftsCntDown then
  15.                 -- shift down
  16.                 self:setClutchState(true);
  17.                 local minG = 0;
  18.                 if rpmShiftPercentage > 1.2 then -- only allow to shift in neutral if engine is under no load
  19.                         minG = 1;                    -- prevents automatic from shifting into neutral if rpm goes down below threshold in 1. Gear
  20.                 end;
  21.                 self:setGear(math.max(self.td.curGear-1, minG));
  22.                 self:engageClutchTimeBySpeed(kmh);
  23.                 self.timeBetweenShiftsCntDown = true;
  24.         end;
  25.         if self.timeBetweenShiftsCntDown then -- count to certain time before next shift action occurs.. (simple dirty way of preventing constantly down/up shifting)
  26.                 self.timeBetweenShiftsCnt = self.timeBetweenShiftsCnt +dt;
  27.                 if self.timeBetweenShiftsCnt >= self.timeBetweenShifts then
  28.                         self.timeBetweenShiftsCntDown = false;
  29.                         self.timeBetweenShiftsCnt = 0;
  30.                 end;
  31.         end;
  32. end;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top