slomal bahui

This commit is contained in:
Никита Круглицкий
2025-05-14 18:57:41 +06:00
parent 6a128f470b
commit 138d91b9f9
12 changed files with 233 additions and 86 deletions

View File

@@ -1,9 +1,11 @@
--@include /koptilnya/libs/watcher.txt
--@include /koptilnya/libs/utils.txt
--@include ./base.txt
local BaseGearbox = require('./base.txt')
require('/koptilnya/libs/watcher.txt')
require('/koptilnya/libs/utils.txt')
local ManualGearbox = class('ManualGearbox', BaseGearbox)
@@ -13,7 +15,7 @@ function ManualGearbox:initialize(vehicle, name, config)
if CLIENT then return end
table.merge(self.wireOutputs, {
Gearbox_Gear = 'number'
[string.format('%s_Gear', self.name)] = 'number'
})
self.ratios = config.Ratios or { 3.6, 2.2, 1.5, 1.2, 1.0, 0.8}
@@ -22,6 +24,8 @@ function ManualGearbox:initialize(vehicle, name, config)
self.gear = 0
function shiftFunc()
if wire.ports.Clutch == 0 then return 0 end
local upshift = wire.ports.Upshift or 0
local downshift = wire.ports.Downshift or 0
@@ -40,13 +44,17 @@ end
function ManualGearbox:updateWireOutputs()
BaseGearbox.updateWireOutputs(self)
wire.ports.Gearbox_Gear = self.gear
wire.ports[string.format('%s_Gear', self.name)] = self.gear
end
function ManualGearbox:setGear(gear)
if gear >= -1 and gear <= #self.ratios then
self.gear = gear
self:recalcRatio()
net.start('GEARBOX_GEAR')
net.writeInt(gear, 5)
net.send(self.vehicle.playersConnectedToHUD, true)
end
end
@@ -65,9 +73,9 @@ function ManualGearbox:shift(dir)
end
function ManualGearbox:forwardStep(torque, inertia)
local result = BaseGearbox.forwardStep(self, torque, inertia)
self.shiftWatcher()
local result = BaseGearbox.forwardStep(self, torque, inertia)
return result
end