78 lines
1.5 KiB
Plaintext
78 lines
1.5 KiB
Plaintext
-- @name Koptilnya Engine
|
|
-- @author Koptilnya1337
|
|
-- @server
|
|
--
|
|
-- @include ./engine.txt
|
|
--
|
|
-- @include ./clutch.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("./clutch.txt")
|
|
--
|
|
require("./gearboxes/manual.txt")
|
|
require("./gearboxes/cvt.txt")
|
|
require("./gearboxes/auto.txt")
|
|
--
|
|
require("./differential.txt")
|
|
--
|
|
require("./configs/audi_tt.txt")
|
|
|
|
ECU = class("ECU")
|
|
|
|
function ECU:initialize(options)
|
|
options = options or {}
|
|
|
|
self.engine = options.Engine
|
|
self.clutch = options.Clutch
|
|
self.gearbox = options.Gearbox
|
|
self.differentials = options.Differentials
|
|
self.input = {}
|
|
|
|
self:adjustPorts()
|
|
|
|
hook.add('tick', 'ecu_update', function()
|
|
self:update()
|
|
end)
|
|
end
|
|
|
|
function ECU:adjustPorts()
|
|
wire.adjustPorts({
|
|
Input = "table"
|
|
}, {
|
|
RPM = "number",
|
|
Torque = "number"
|
|
})
|
|
end
|
|
|
|
function ECU:update()
|
|
wire.ports.RPM = self.engine.rpm
|
|
wire.ports.Torque = self.engine.torque
|
|
|
|
self.input = wire.ports.Input
|
|
|
|
self.engine:setThrottle(self.input.Throttle.Value)
|
|
self.engine:update()
|
|
end
|
|
|
|
local clutch = Clutch:new(config.Clutch)
|
|
|
|
local engine = Engine:new(config.Engine)
|
|
engine:linkClutch(clutch)
|
|
|
|
local gearbox = ManualGearbox:new(config.Gearbox)
|
|
gearbox:linkClutch(clutch)
|
|
|
|
local ecu = ECU:new({
|
|
Engine = engine,
|
|
Clutch = clutch
|
|
-- Gearbox = gearbox
|
|
})
|