Implementing starfall version of engine
This commit is contained in:
parent
a5f7bedf8d
commit
e2c1c4bc88
5
koptilnya/.vscode/settings.json
vendored
Normal file
5
koptilnya/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"*.txt": "lua"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -49,7 +49,7 @@ local Materials =
|
|||||||
|
|
||||||
local Colors =
|
local Colors =
|
||||||
{
|
{
|
||||||
Body = Color(255,255,255),
|
Body = Color(230,230,222),
|
||||||
Shadow = Color(25,25,25),
|
Shadow = Color(25,25,25),
|
||||||
Grille = Color(130,130,130),
|
Grille = Color(130,130,130),
|
||||||
WindowsOutline = Color(30,30,30),
|
WindowsOutline = Color(30,30,30),
|
||||||
|
|||||||
16
koptilnya/engine/clutch.txt
Normal file
16
koptilnya/engine/clutch.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Clutch = class("Clutch")
|
||||||
|
|
||||||
|
function Clutch:initialize(options)
|
||||||
|
options = options or {}
|
||||||
|
|
||||||
|
self.stiffness = options.Stiffness or 0
|
||||||
|
self.capacity = options.Capacity or 0
|
||||||
|
self.damping = options.Damping or 0
|
||||||
|
|
||||||
|
self._engine = options.Engine
|
||||||
|
self._gearbox = options.Gearbox
|
||||||
|
end
|
||||||
|
|
||||||
|
function Clutch:update()
|
||||||
|
|
||||||
|
end
|
||||||
55
koptilnya/engine/configs/audi_tt.txt
Normal file
55
koptilnya/engine/configs/audi_tt.txt
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
config = {
|
||||||
|
Engine = {
|
||||||
|
IdleRPM = 800,
|
||||||
|
MaxRPM = 6500,
|
||||||
|
FlywheelMass = 4.9,
|
||||||
|
FlywheelRadius = 0.378,
|
||||||
|
StartFriction = -50,
|
||||||
|
FrictionCoeff = 0.02,
|
||||||
|
LimiterDuration = 0.05,
|
||||||
|
TorqueMap = {240.29618749947, 251.33093929699, 262.3656910945, 273.40044289202, 284.43519468953,
|
||||||
|
295.46994648705, 306.50469828456, 317.53945008208, 328.57420187959, 339.60895367711,
|
||||||
|
350.64370547463, 361.67845727214, 372.71320906966, 383.74796086717, 394.78271266469,
|
||||||
|
405.8174644622, 416.85221625972, 427.88696805724, 438.92171985475, 449.95647165227, 449.9557104607,
|
||||||
|
449.95494926913, 449.95418807757, 449.953426886, 449.95266569443, 449.95190450287, 449.9511433113,
|
||||||
|
449.95038211973, 449.94962092816, 449.9488597366, 449.94809854503, 449.94733735346, 449.9465761619,
|
||||||
|
449.94581497033, 449.94505377876, 449.9442925872, 449.94353139563, 449.94277020406,
|
||||||
|
449.94200901249, 449.94124782093, 449.94048662936, 449.93972543779, 449.93896424623,
|
||||||
|
449.93820305466, 449.93744186309, 449.93668067153, 449.93591947996, 449.93515828839,
|
||||||
|
449.93439709682, 449.93363590526, 449.93287471369, 449.93211352212, 449.93135233056,
|
||||||
|
449.93059113899, 449.92982994742, 449.92906875586, 449.92830756429, 449.92754637272,
|
||||||
|
449.92678518115, 449.92602398959, 449.92526279802, 449.92450160645, 449.92374041489,
|
||||||
|
449.92297922332, 449.92221803175, 449.92145684019, 449.92069564862, 449.91993445705,
|
||||||
|
449.91917326548, 449.91841207392, 449.91765088235, 449.91688969078, 449.91612849922,
|
||||||
|
446.34504740794, 442.77396631665, 439.20288522537, 435.63180413409, 432.06072304281,
|
||||||
|
428.48964195153, 424.91856086025, 421.34747976897, 417.77639867769, 414.2053175864,
|
||||||
|
410.63423649512, 407.06315540384, 403.49207431256, 399.92099322128, 396.34991213, 392.77883103872,
|
||||||
|
389.20774994744, 385.63666885615, 382.06558776487, 378.49450667359, 374.92342558231,
|
||||||
|
371.35234449103, 367.78126339975, 364.21018230847, 360.63910121719, 357.0680201259,
|
||||||
|
353.49693903462, 349.92585794334}
|
||||||
|
},
|
||||||
|
Clutch = {
|
||||||
|
Stiffness = 22,
|
||||||
|
Capacity = 1.3,
|
||||||
|
Damping = 0.5
|
||||||
|
},
|
||||||
|
Gearbox = {
|
||||||
|
Ratios = {2.93, 1.96, 1.38, 1.03, 1.06, 0.87},
|
||||||
|
Reverse = 3.26,
|
||||||
|
FinalDrive = 4.77
|
||||||
|
},
|
||||||
|
FrontDiff = {
|
||||||
|
Power = 0.25,
|
||||||
|
Coast = 0.15,
|
||||||
|
Preload = 10,
|
||||||
|
UsePowerBias = 10,
|
||||||
|
ViscousCoeff = 0.96
|
||||||
|
},
|
||||||
|
RearDiff = {
|
||||||
|
Power = 0.25,
|
||||||
|
Coast = 0.15,
|
||||||
|
Preload = 10,
|
||||||
|
UsePowerBias = 10,
|
||||||
|
ViscousCoeff = 0.96
|
||||||
|
}
|
||||||
|
}
|
||||||
18
koptilnya/engine/differential.txt
Normal file
18
koptilnya/engine/differential.txt
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
Differential = class("Differential")
|
||||||
|
|
||||||
|
function Differential:initialize(options)
|
||||||
|
options = options or {}
|
||||||
|
|
||||||
|
self.power = options.Power or 1
|
||||||
|
self.coast = options.Coast or 1
|
||||||
|
self.preload = options.Preload or 10
|
||||||
|
self.viscousCoeff = options.ViscousCoeff or 0.9
|
||||||
|
|
||||||
|
self._gearbox = options.Gearbox
|
||||||
|
self._leftWheel = options.LeftWheel
|
||||||
|
self._rightWheel = options.RightWheel
|
||||||
|
|
||||||
|
if self._gearbox then
|
||||||
|
self._gearbox:linkDiff(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
Engine = class("Engine")
|
||||||
|
|
||||||
|
function Engine:initialize(options)
|
||||||
|
options = options or {}
|
||||||
|
|
||||||
|
self.idleRPM = options.IdleRPM or 800
|
||||||
|
self.maxRPM = options.MaxRPM or 8000
|
||||||
|
|
||||||
|
self.flywheelMass = options.FlywheelMass or 4
|
||||||
|
self.flywheelRadius = options.FlywheelRadius or 0.3
|
||||||
|
|
||||||
|
self.startFriction = options.StartFriction or -30
|
||||||
|
self.frictionCoeff = options.FrictionCoeff or 0.02
|
||||||
|
|
||||||
|
self.limiterDuration = options.LimiterDuration or 0.05
|
||||||
|
|
||||||
|
self.torqueMap = options.TorqueMap or {}
|
||||||
|
|
||||||
|
self.throttle = 0
|
||||||
|
end
|
||||||
4
koptilnya/engine/gearboxes/auto.txt
Normal file
4
koptilnya/engine/gearboxes/auto.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
-- @include ./base.txt
|
||||||
|
require("./base.txt")
|
||||||
|
|
||||||
|
AutomaticGearbox = class("AutomaticGearbox")
|
||||||
28
koptilnya/engine/gearboxes/base.txt
Normal file
28
koptilnya/engine/gearboxes/base.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Gearbox = class("Gearbox")
|
||||||
|
|
||||||
|
function Gearbox:initialize(options)
|
||||||
|
options = options or {}
|
||||||
|
|
||||||
|
self.ratios = options.ratios
|
||||||
|
self.finalDrive = options.finalDrive
|
||||||
|
|
||||||
|
self._linkedDiffs = {}
|
||||||
|
|
||||||
|
self.gear = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function Gearbox:linkDiff(diff)
|
||||||
|
table.insert(self._linkedDiffs, diff)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Gearbox:shift(dir)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function Gearbox:setGear(gear)
|
||||||
|
self.gear = gear
|
||||||
|
end
|
||||||
|
|
||||||
|
function Gearbox:update()
|
||||||
|
|
||||||
|
end
|
||||||
4
koptilnya/engine/gearboxes/cvt.txt
Normal file
4
koptilnya/engine/gearboxes/cvt.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
-- @include ./base.txt
|
||||||
|
require("./base.txt")
|
||||||
|
|
||||||
|
CVT = class("CVT")
|
||||||
10
koptilnya/engine/gearboxes/manual.txt
Normal file
10
koptilnya/engine/gearboxes/manual.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
-- @include ./base.txt
|
||||||
|
require("./base.txt")
|
||||||
|
|
||||||
|
ManualGearbox = class("ManualGearbox")
|
||||||
|
|
||||||
|
function ManualGearbox:initialize(options)
|
||||||
|
-- create base gearbox inside
|
||||||
|
end
|
||||||
|
|
||||||
|
-- proxy the methods here
|
||||||
@ -1,3 +1,42 @@
|
|||||||
-- @name Koptilnya Engine
|
-- @name Koptilnya Engine
|
||||||
-- @author Koptilnya1337
|
-- @author Koptilnya1337
|
||||||
-- @shared
|
-- @shared
|
||||||
|
--
|
||||||
|
-- @include ./engine.txt
|
||||||
|
--
|
||||||
|
-- @include ./gearboxes/manual.txt
|
||||||
|
-- @include ./gearboxes/cvt.txt
|
||||||
|
-- @include ./gearboxes/auto.txt
|
||||||
|
--
|
||||||
|
-- @include ./differential.txt
|
||||||
|
--
|
||||||
|
-- @include ./configs/audi_tt.txt
|
||||||
|
require("./engine.txt")
|
||||||
|
--
|
||||||
|
require("./gearboxes/manual.txt")
|
||||||
|
require("./gearboxes/cvt.txt")
|
||||||
|
require("./gearboxes/auto.txt")
|
||||||
|
--
|
||||||
|
require("./differential.txt")
|
||||||
|
--
|
||||||
|
require("./configs/audi_tt.txt")
|
||||||
|
|
||||||
|
if SERVER then
|
||||||
|
function adjustPorts()
|
||||||
|
wire.adjustPorts({
|
||||||
|
Input = "table"
|
||||||
|
}, {
|
||||||
|
RPM = "number"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
function setupHooks()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
adjustPorts()
|
||||||
|
-- printTable(config)
|
||||||
|
else
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
@ -30,9 +30,6 @@ function Input:getAxleValue(axle)
|
|||||||
local positiveValue = axle.Positive ~= nil and input.isKeyDown(axle.Positive)
|
local positiveValue = axle.Positive ~= nil and input.isKeyDown(axle.Positive)
|
||||||
local negativeValue = axle.Negative ~= nil and input.isKeyDown(axle.Negative)
|
local negativeValue = axle.Negative ~= nil and input.isKeyDown(axle.Negative)
|
||||||
|
|
||||||
print(positiveValue)
|
|
||||||
print(negativeValue)
|
|
||||||
|
|
||||||
return (positiveValue and 1 or 0) - (negativeValue and 1 or 0) -- (input.isKeyDown(axle.Positive) and 1 or 0) - (input.isKeyDown(axle.Negative) and 1 or 0)
|
return (positiveValue and 1 or 0) - (negativeValue and 1 or 0) -- (input.isKeyDown(axle.Positive) and 1 or 0) - (input.isKeyDown(axle.Negative) and 1 or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user