Finished stuff with manual gearbox
This commit is contained in:
@@ -5,30 +5,21 @@ require('./base.txt')
|
||||
|
||||
ManualGearbox = class('ManualGearbox', Gearbox)
|
||||
|
||||
function ManualGearbox:initialize(config, clutch)
|
||||
Gearbox.initialize(self, config, clutch)
|
||||
function ManualGearbox:initialize(...)
|
||||
Gearbox.initialize(self, ...)
|
||||
|
||||
-- self.ratios = config.Ratios
|
||||
-- self.reverse = config.Reverse
|
||||
function shiftFunc()
|
||||
local upshift = wire.ports.Upshift or 0
|
||||
local downshift = wire.ports.Downshift or 0
|
||||
|
||||
-- self.rpm = 0
|
||||
-- self.torque = 0
|
||||
-- self.gear = 0
|
||||
return upshift - downshift
|
||||
end
|
||||
|
||||
-- self:recalcRatio()
|
||||
|
||||
-- self.axles = {}
|
||||
-- self.clutch = nil
|
||||
|
||||
-- self.torque = 0
|
||||
|
||||
-- self.shiftWatcher = watcher(function()
|
||||
-- return wire.ports.Upshift - wire.ports.Downshift
|
||||
-- end, function(val)
|
||||
-- if val ~= 0 then
|
||||
-- self:shift(val)
|
||||
-- end
|
||||
-- end)
|
||||
self.shiftWatcher = watcher(shiftFunc, function(val)
|
||||
if val ~= 0 then
|
||||
self:shift(val)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function ManualGearbox:recalcRatio()
|
||||
@@ -41,36 +32,23 @@ function ManualGearbox:recalcRatio()
|
||||
end
|
||||
end
|
||||
|
||||
function ManualGearbox:getInputs()
|
||||
return {
|
||||
Upshift = 'number',
|
||||
Downshift = 'number'
|
||||
}
|
||||
function ManualGearbox:shift(dir)
|
||||
self:setGear(self.gear + dir)
|
||||
end
|
||||
|
||||
function ManualGearbox:getOutputs()
|
||||
return {
|
||||
Gearbox_RPM = 'number',
|
||||
Gearbox_Torque = 'number'
|
||||
}
|
||||
end
|
||||
-- function ManualGearbox:getOutputs()
|
||||
-- return {
|
||||
-- Gearbox_RPM = 'number',
|
||||
-- Gearbox_Torque = 'number'
|
||||
-- }
|
||||
-- end
|
||||
|
||||
function ManualGearbox:updateOutputs()
|
||||
-- function ManualGearbox:updateOutputs()
|
||||
|
||||
end
|
||||
-- end
|
||||
|
||||
function ManualGearbox:update()
|
||||
-- if self.clutch ~= nil then
|
||||
-- self.torque = self.clutch.torque * self.ratio
|
||||
-- end
|
||||
Gearbox.update(self)
|
||||
|
||||
-- local axlesRPM = table.map(self.axles, function(diff)
|
||||
-- return diff.avgRPM
|
||||
-- end)
|
||||
|
||||
-- local maxAxlesRPM = math.max(unpack(axlesRPM))
|
||||
|
||||
-- self.rpm = maxAxlesRPM * self.ratio
|
||||
|
||||
-- self.shiftWatcher()
|
||||
self.shiftWatcher()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user