Implemented engine
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
-- @name Koptilnya Engine
|
||||
-- @author Koptilnya1337
|
||||
-- @shared
|
||||
-- @server
|
||||
--
|
||||
-- @include ./engine.txt
|
||||
--
|
||||
-- @include ./clutch.txt
|
||||
--
|
||||
-- @include ./gearboxes/manual.txt
|
||||
-- @include ./gearboxes/cvt.txt
|
||||
-- @include ./gearboxes/auto.txt
|
||||
@@ -13,6 +15,8 @@
|
||||
-- @include ./configs/audi_tt.txt
|
||||
require("./engine.txt")
|
||||
--
|
||||
require("./clutch.txt")
|
||||
--
|
||||
require("./gearboxes/manual.txt")
|
||||
require("./gearboxes/cvt.txt")
|
||||
require("./gearboxes/auto.txt")
|
||||
@@ -21,22 +25,54 @@ require("./differential.txt")
|
||||
--
|
||||
require("./configs/audi_tt.txt")
|
||||
|
||||
if SERVER then
|
||||
function adjustPorts()
|
||||
wire.adjustPorts({
|
||||
Input = "table"
|
||||
}, {
|
||||
RPM = "number"
|
||||
})
|
||||
end
|
||||
ECU = class("ECU")
|
||||
|
||||
function setupHooks()
|
||||
function ECU:initialize(options)
|
||||
options = options or {}
|
||||
|
||||
end
|
||||
self.engine = options.Engine
|
||||
self.clutch = options.Clutch
|
||||
self.gearbox = options.Gearbox
|
||||
self.differentials = options.Differentials
|
||||
self.input = {}
|
||||
|
||||
adjustPorts()
|
||||
-- printTable(config)
|
||||
else
|
||||
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
|
||||
})
|
||||
-- printTable(config)
|
||||
|
||||
Reference in New Issue
Block a user