asd
This commit is contained in:
parent
ad267f034b
commit
7cdb222580
@ -57,19 +57,8 @@ if SERVER then
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
function init()
|
PERMA.onPermissionsGained = function()
|
||||||
builder = MeshBuilder:new(LINK)
|
builder = MeshBuilder:new(LINK)
|
||||||
end
|
end
|
||||||
|
PERMA.build()
|
||||||
if hasPermission("http.get") and hasPermission("mesh") and hasPermission("entities.setRenderProperty", chip()) then
|
|
||||||
init()
|
|
||||||
else
|
|
||||||
setupPermissionRequest({"http.get", "mesh", "entities.setRenderProperty"}, "", true)
|
|
||||||
|
|
||||||
hook.add("permissionrequest", "_permissionrequest", function()
|
|
||||||
if permissionRequestSatisfied() then
|
|
||||||
init()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
@ -1,5 +1,7 @@
|
|||||||
-- @include ./wire_component.txt
|
-- @include ./wire_component.txt
|
||||||
-- @include ./enums/gearbox.txt
|
-- @include ./enums/gearbox.txt
|
||||||
|
-- @include /koptilnya/libs/constants.txt
|
||||||
|
require('/koptilnya/libs/constants.txt')
|
||||||
require('./wire_component.txt')
|
require('./wire_component.txt')
|
||||||
local gearboxTypes = require('./enums/gearbox.txt')
|
local gearboxTypes = require('./enums/gearbox.txt')
|
||||||
|
|
||||||
@ -58,14 +60,12 @@ function Clutch:getPress()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Clutch:update()
|
function Clutch:update()
|
||||||
local someConversionCoeff = 0.10472
|
|
||||||
|
|
||||||
local engRPM = self.engine and self.engine.rpm or 0
|
local engRPM = self.engine and self.engine.rpm or 0
|
||||||
local gboxRPM = self.gearbox and self.gearbox.rpm or 0
|
local gboxRPM = self.gearbox and self.gearbox.rpm or 0
|
||||||
local gboxRatio = self.gearbox and self.gearbox.ratio or 0
|
local gboxRatio = self.gearbox and self.gearbox.ratio or 0
|
||||||
local gboxRatioNotZero = gboxRatio ~= 0 and 1 or 0
|
local gboxRatioNotZero = gboxRatio ~= 0 and 1 or 0
|
||||||
|
|
||||||
self.slip = ((engRPM - gboxRPM) * someConversionCoeff) * gboxRatioNotZero / 2
|
self.slip = ((engRPM - gboxRPM) * RPM_TO_RAD) * gboxRatioNotZero / 2
|
||||||
self.targetTorque = math.clamp(self.slip * self.stiffness * (1 - self:getPress()), -self.maxTorque, self.maxTorque)
|
self.targetTorque = math.clamp(self.slip * self.stiffness * (1 - self:getPress()), -self.maxTorque, self.maxTorque)
|
||||||
|
|
||||||
self.torque = math.lerp(self.damping, self.torque, self.targetTorque)
|
self.torque = math.lerp(self.damping, self.torque, self.targetTorque)
|
||||||
|
|||||||
32
koptilnya/engine_remastered/configs/fiat595.txt
Normal file
32
koptilnya/engine_remastered/configs/fiat595.txt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
-- @name Fiat 595
|
||||||
|
-- @author Koptilnya1337
|
||||||
|
-- @server
|
||||||
|
-- @include /koptilnya/engine_remastered/vehicle.txt
|
||||||
|
require('/koptilnya/engine_remastered/vehicle.txt')
|
||||||
|
|
||||||
|
Vehicle:new({
|
||||||
|
Engine = {
|
||||||
|
IdleRPM = 900,
|
||||||
|
MaxRPM = 7500,
|
||||||
|
FlywheelMass = 1.4,
|
||||||
|
FlywheelRadius = 0.278,
|
||||||
|
StartFriction = -6,
|
||||||
|
FrictionCoeff = 0.01,
|
||||||
|
LimiterDuration = 0.05,
|
||||||
|
TorqueMap = {
|
||||||
|
30.017853095232, 30.031749070172, 30.045645045111, 30.059541020051, 30.073436994991, 30.08733296993, 30.10122894487, 30.115124919809, 30.129020894749, 30.142916869689, 30.171157076824, 30.199397283959, 30.227637491094, 30.25587769823, 30.284117905365, 30.3123581125,
|
||||||
|
30.340598319636, 30.368838526771, 30.397078733906, 30.957848420602, 31.518618107297, 32.079387793992, 32.640157480687, 33.200927167383, 33.761696854078, 34.322466540773, 34.646220344003, 34.969974147233, 35.293727950462, 35.617481753692, 35.941235556922,
|
||||||
|
36.264989360151, 36.588743163381, 36.912496966611, 37.236250769841, 37.56000457307, 37.596187338462, 37.632370103855, 37.668552869247, 37.704735634639, 37.740918400031, 37.777101165423, 37.813283930815, 37.849466696207, 37.885649461599, 37.921832226991,
|
||||||
|
37.958014992384, 37.994197757776, 38.030380523168, 38.06656328856, 38.102746053952, 38.138928819344, 38.136555692694, 38.134182566044, 38.131809439394, 38.129436312744, 38.127063186094, 38.124690059444, 38.122316932794, 38.119943806144, 38.117570679494,
|
||||||
|
38.115197552844, 38.112824426194, 38.110451299544, 38.108078172894, 38.105705046244, 38.103331919594, 38.100958792944, 38.098585666294, 37.885631451263, 37.672677236233, 37.459723021202, 37.246768806172, 37.033814591141, 36.820860376111, 36.60790616108,
|
||||||
|
35.469220912467, 34.330535663853, 33.19185041524, 32.053165166627, 31.630368922658, 31.207572678689, 30.784776434721, 30.361980190752, 29.939183946784, 29.629298102415, 29.319412258047, 29.009526413678, 28.699640569309, 28.389754724941, 28.079868880572,
|
||||||
|
27.769983036203, 27.460097191835, 27.150211347466, 26.840325503097, 26.530439658729, 26.22055381436, 25.910667969992, 25.600782125623, 25.290896281254, 24.981010436886
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Clutch = {Stiffness = 7, Damping = 0.4, MaxTorque = 70},
|
||||||
|
Gearbox = {Type = 'MANUAL', ShiftDuration = 0.2, ShiftSmoothness = 0.3, Ratios = {3.273, 2.067, 1.3, 1.075}, Reverse = 3.818},
|
||||||
|
Axles = {
|
||||||
|
{Power = 0.04, Coast = 0.04, Preload = 10, UsePowerBias = 10, ViscousCoeff = 0.96, Axle = Vector(1, 0, 0), DistributionCoeff = 1, FinalDrive = 4.134}
|
||||||
|
},
|
||||||
|
Systems = {{Type = 'LAUNCH', Limit = 3500}, {Type = 'TRACTION', Limit = 1.5}}
|
||||||
|
})
|
||||||
30
koptilnya/engine_remastered/configs/overpower_bus.txt
Normal file
30
koptilnya/engine_remastered/configs/overpower_bus.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
-- @name Overpower bus
|
||||||
|
-- @author Koptilnya1337
|
||||||
|
-- @server
|
||||||
|
-- @include /koptilnya/engine_remastered/vehicle.txt
|
||||||
|
require('/koptilnya/engine_remastered/vehicle.txt')
|
||||||
|
|
||||||
|
Vehicle:new({
|
||||||
|
Engine = {
|
||||||
|
IdleRPM = 850,
|
||||||
|
MaxRPM = 5000,
|
||||||
|
FlywheelMass = 4,
|
||||||
|
FlywheelRadius = 0.419,
|
||||||
|
StartFriction = -140,
|
||||||
|
FrictionCoeff = 0.1,
|
||||||
|
LimiterDuration = 0.02,
|
||||||
|
TorqueMap = {
|
||||||
|
1501.5113728322, 1586.1989550577, 1670.8865372833, 1755.5741195088, 1840.2617017344, 1924.9492839599, 2009.6368661855, 2094.324448411, 2179.0120306366, 2263.6996128621, 2348.3871950877, 2433.0747773133, 2517.7623595388, 2602.4499417644, 2660.7319564554,
|
||||||
|
2719.0139711464, 2777.2959858374, 2835.5780005284, 2893.8600152194, 2952.1420299105, 3010.4240446015, 3068.7060592925, 3126.9880739835, 3185.2700886745, 3243.5521033656, 3301.8341180566, 3317.1458978142, 3332.4576775719, 3347.7694573296, 3363.0812370872,
|
||||||
|
3378.3930168449, 3393.7047966026, 3409.0165763602, 3424.3283561179, 3439.6401358756, 3454.9519156332, 3470.2636953909, 3485.5754751486, 3500.8872549062, 3476.0560425621, 3451.224830218, 3426.3936178739, 3401.5624055298, 3376.7311931857, 3351.8999808416,
|
||||||
|
3327.0687684975, 3302.2375561533, 3277.4063438092, 3252.5751314651, 3227.743919121, 3202.9127067769, 3186.1097868145, 3169.3068668522, 3152.5039468898, 3135.7010269274, 3118.8981069651, 3102.0951870027, 3085.2922670403, 3068.4893470779, 3051.6864271156,
|
||||||
|
3034.8835071532, 3018.0805871908, 3001.2776672285, 2970.5175646872, 2939.757462146, 2908.9973596048, 2878.2372570636, 2847.4771545223, 2816.7170519811, 2785.9569494399, 2755.1968468987, 2724.4367443575, 2693.6766418162, 2662.916539275, 2632.1564367338,
|
||||||
|
2601.3963341926, 2551.9181162298, 2502.4398982671, 2452.9616803043, 2403.4834623416, 2354.0052443788, 2304.5270264161, 2255.0488084533, 2205.5705904905, 2162.834347669, 2120.0981048475, 2077.3618620259, 2034.6256192044, 1991.8893763829, 1949.1531335613,
|
||||||
|
1906.4168907398, 1863.6806479182, 1820.9444050967, 1778.2081622752, 1735.4719194536, 1692.7356766321, 1649.9994338105, 1607.263190989, 1564.5269481675, 1521.7907053459, 1479.0544625244
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Clutch = {Stiffness = 80, Damping = 0.5, MaxTorque = 5000},
|
||||||
|
Gearbox = {Type = 'MANUAL', ShiftDuration = 0.2, ShiftSmoothness = 0.3, Ratios = {2.7, 1.9, 1.46, 1.14, 0.94, 0.78}, Reverse = 2.6},
|
||||||
|
Axles = {{Power = 0.96, Coast = 0.96, Preload = 10, UsePowerBias = 10, ViscousCoeff = 0.96, Axle = Vector(1, 0, 0), DistributionCoeff = 1, FinalDrive = 3.9}},
|
||||||
|
Systems = {{Type = 'LAUNCH', Limit = 3500}, {Type = 'TRACTION', Limit = 1.5}}
|
||||||
|
})
|
||||||
@ -26,7 +26,6 @@ Vehicle:new({
|
|||||||
Clutch = {Stiffness = 20, Damping = 0.5, MaxTorque = 400},
|
Clutch = {Stiffness = 20, Damping = 0.5, MaxTorque = 400},
|
||||||
Gearbox = {Type = 'MANUAL', ShiftDuration = 0.2, ShiftSmoothness = 0.3, Ratios = {3.321, 1.902, 1.308, 1, 0.838}, Reverse = 3.382},
|
Gearbox = {Type = 'MANUAL', ShiftDuration = 0.2, ShiftSmoothness = 0.3, Ratios = {3.321, 1.902, 1.308, 1, 0.838}, Reverse = 3.382},
|
||||||
Axles = {
|
Axles = {
|
||||||
{Power = 0.5, Coast = 0.3, Preload = 30, ViscousCoeff = 0.96, Axle = Vector(1, 0, 0), DistributionCoeff = 1, FinalDrive = 4.08},
|
|
||||||
{Power = 0.96, Coast = 0.96, Preload = 10, UsePowerBias = 10, ViscousCoeff = 0.96, Axle = Vector(1, 0, 0), DistributionCoeff = 1, FinalDrive = 3.9}
|
{Power = 0.96, Coast = 0.96, Preload = 10, UsePowerBias = 10, ViscousCoeff = 0.96, Axle = Vector(1, 0, 0), DistributionCoeff = 1, FinalDrive = 3.9}
|
||||||
},
|
},
|
||||||
Systems = {{Type = 'LAUNCH', Limit = 3500}, {Type = 'TRACTION', Limit = 1.5}}
|
Systems = {{Type = 'LAUNCH', Limit = 3500}, {Type = 'TRACTION', Limit = 1.5}}
|
||||||
|
|||||||
30
koptilnya/engine_remastered/configs/sx240_stock.txt
Normal file
30
koptilnya/engine_remastered/configs/sx240_stock.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
-- @name SX 240
|
||||||
|
-- @author Koptilnya1337
|
||||||
|
-- @server
|
||||||
|
-- @include /koptilnya/engine_remastered/vehicle.txt
|
||||||
|
require('/koptilnya/engine_remastered/vehicle.txt')
|
||||||
|
|
||||||
|
Vehicle:new({
|
||||||
|
Engine = {
|
||||||
|
IdleRPM = 900,
|
||||||
|
MaxRPM = 7500,
|
||||||
|
FlywheelMass = 4.1,
|
||||||
|
FlywheelRadius = 0.35,
|
||||||
|
StartFriction = -30,
|
||||||
|
FrictionCoeff = 0.02,
|
||||||
|
LimiterDuration = 0.05,
|
||||||
|
TorqueMap = {
|
||||||
|
134.98999798272, 135.76485966224, 136.53972134176, 137.31458302129, 138.08944470081, 138.86430638033, 139.63916805985, 140.41402973937, 141.1888914189, 141.96375309842, 142.73861477794, 143.76817204379, 144.79772930963, 145.82728657548, 146.85684384133,
|
||||||
|
147.88640110718, 148.91595837302, 149.94551563887, 150.97507290472, 152.00463017056, 153.03418743641, 154.68960148325, 156.34501553008, 158.00042957692, 159.09171186693, 160.18299415695, 161.27427644696, 162.36555873698, 163.66326349343, 164.96096824989,
|
||||||
|
166.25867300634, 166.9213678651, 167.58406272386, 168.24675758262, 168.42447518085, 168.60219277908, 168.77991037731, 168.95762797554, 168.68490826092, 168.41218854629, 168.13946883167, 167.86674911705, 167.59402940243, 167.10537320734, 166.61671701226,
|
||||||
|
166.12806081717, 165.63940462208, 165.15074842699, 164.6620922319, 164.17343603681, 163.68477984173, 163.68235925254, 163.67993866336, 163.67751807418, 163.67509748499, 163.67267689581, 163.80869095467, 163.94470501352, 164.08071907238, 164.21673313123,
|
||||||
|
164.35274719009, 164.48876124894, 164.6247753078, 164.56345371516, 164.50213212253, 164.44081052989, 164.37948893725, 164.31816734462, 163.9026328682, 163.48709839178, 163.07156391536, 162.65602943894, 162.24049496252, 161.61921040554, 160.99792584857,
|
||||||
|
160.37664129159, 159.75535673461, 159.13407217764, 158.51278762066, 157.22180672305, 155.93082582543, 154.63984492782, 153.3488640302, 152.4949339573, 151.6410038844, 150.7870738115, 149.9331437386, 149.0792136657, 148.2252835928, 147.3713535199, 146.517423447,
|
||||||
|
145.6634933741, 144.90011126693, 144.13672915977, 143.3733470526, 142.60996494544, 141.84658283827, 141.0832007311, 140.31981862394, 139.55643651677, 138.79305440961
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Clutch = {Stiffness = 20, Damping = 0.7, MaxTorque = 400},
|
||||||
|
Gearbox = {Type = 'MANUAL', ShiftDuration = 0.2, ShiftSmoothness = 0.3, Ratios = {3.626, 2.200, 1.541, 1.213, 1.000, 0.767}, Reverse = 3.437},
|
||||||
|
Axles = {{Power = 0.96, Coast = 0.96, Preload = 10, UsePowerBias = 10, ViscousCoeff = 0.96, Axle = Vector(1, 0, 0), DistributionCoeff = 1, FinalDrive = 3.392}},
|
||||||
|
Systems = {{Type = 'LAUNCH', Limit = 3500}, {Type = 'TRACTION', Limit = 1.5}}
|
||||||
|
})
|
||||||
30
koptilnya/engine_remastered/configs/vaz.txt
Normal file
30
koptilnya/engine_remastered/configs/vaz.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
-- @name VAZ
|
||||||
|
-- @author Koptilnya1337
|
||||||
|
-- @server
|
||||||
|
-- @include /koptilnya/engine_remastered/vehicle.txt
|
||||||
|
require('/koptilnya/engine_remastered/vehicle.txt')
|
||||||
|
|
||||||
|
Vehicle:new({
|
||||||
|
Engine = {
|
||||||
|
IdleRPM = 1000,
|
||||||
|
MaxRPM = 6000,
|
||||||
|
FlywheelMass = 6.1,
|
||||||
|
FlywheelRadius = 0.278,
|
||||||
|
StartFriction = -50,
|
||||||
|
FrictionCoeff = 0.02,
|
||||||
|
LimiterDuration = 0.05,
|
||||||
|
TorqueMap = {
|
||||||
|
90.084105067783, 91.733751883921, 93.383398700059, 95.033045516198, 96.682692332336, 98.332339148474, 99.981985964612, 101.63163278075, 103.28127959689, 104.93092641303, 106.58057322917, 108.2302200453, 109.54002774767, 110.84983545005, 112.15964315242,
|
||||||
|
113.46945085479, 114.77925855716, 116.08906625953, 117.3988739619, 118.70868166427, 120.01848936664, 120.90160088842, 121.7847124102, 122.66782393198, 123.55093545376, 124.43404697554, 125.31715849732, 126.2002700191, 127.08338154088, 127.96649306266, 128.84960458444,
|
||||||
|
128.93317254433, 129.01674050422, 129.10030846411, 129.183876424, 129.26744438389, 129.35101234378, 129.43458030367, 129.51814826356, 129.60171622345, 129.68528418334, 129.76885214323, 129.85242010312, 129.93598806301, 130.0195560229, 130.54545785704, 131.07135969118,
|
||||||
|
131.59726152532, 132.12316335946, 132.64906519359, 133.17496702773, 133.70086886187, 134.22677069601, 134.75267253015, 135.27857436429, 135.80447619843, 136.33037803256, 136.8562798667, 137.38218170084, 137.35118117271, 137.32018064457, 137.28918011644,
|
||||||
|
137.25817958831, 137.22717906017, 137.19617853204, 137.16517800391, 137.13417747577, 137.10317694764, 137.07217641951, 137.04117589137, 137.01017536324, 136.97917483511, 136.94817430697, 136.91717377884, 136.88617325071, 136.85517272257, 136.82417219444,
|
||||||
|
136.7931716663, 134.83935283794, 132.88553400958, 130.93171518122, 128.97789635286, 127.0240775245, 125.07025869613, 123.11643986777, 121.16262103941, 119.20880221105, 117.25498338269, 114.42320437049, 111.5914253583, 108.7596463461, 105.92786733391, 103.09608832172,
|
||||||
|
100.26430930952, 97.432530297329, 94.600751285135, 91.768972272941, 88.937193260747, 86.105414248553, 83.273635236359, 80.441856224165
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Clutch = {Stiffness = 10, Damping = 0.7, MaxTorque = 200},
|
||||||
|
Gearbox = {Type = 'MANUAL', ShiftDuration = 0.2, ShiftSmoothness = 0.3, Ratios = {3.636, 1.95, 1.357, 0.941, 0.784}, Reverse = 3.53},
|
||||||
|
Axles = {{Power = 0.96, Coast = 0.96, Preload = 10, UsePowerBias = 10, ViscousCoeff = 0.96, Axle = Vector(1, 0, 0), DistributionCoeff = 1, FinalDrive = 3.937}},
|
||||||
|
Systems = {{Type = 'LAUNCH', Limit = 3500}, {Type = 'TRACTION', Limit = 1.5}}
|
||||||
|
})
|
||||||
99
koptilnya/engine_remastered/novojiloff_diff.txt
Normal file
99
koptilnya/engine_remastered/novojiloff_diff.txt
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
-- @server
|
||||||
|
-- @include /koptilnya/libs/constants.txt
|
||||||
|
-- @include ./wire_component.txt
|
||||||
|
require('/koptilnya/libs/constants.txt')
|
||||||
|
require('./wire_component.txt')
|
||||||
|
|
||||||
|
Differential = class('Differential', WireComponent)
|
||||||
|
|
||||||
|
function Differential:initialize(config, order)
|
||||||
|
self.finalDrive = config.FinalDrive or 1
|
||||||
|
self.distributionCoeff = config.DistributionCoeff or 1
|
||||||
|
self.axle = config.Axle or Vector(1, 0, 0)
|
||||||
|
|
||||||
|
self.order = order
|
||||||
|
|
||||||
|
self.avgRPM = 0
|
||||||
|
|
||||||
|
self.prefix = 'Axle' .. self.order .. '_'
|
||||||
|
|
||||||
|
self.leftWheel = wire.ports[self.prefix .. 'LeftWheel']
|
||||||
|
self.rightWheel = wire.ports[self.prefix .. 'RightWheel']
|
||||||
|
|
||||||
|
self.lwav = 0
|
||||||
|
self.rwav = 0
|
||||||
|
|
||||||
|
hook.add('input', 'wire_axle_update' .. self.order, function(key, val)
|
||||||
|
if key == self.prefix .. 'LeftWheel' then
|
||||||
|
self.leftWheel = val
|
||||||
|
end
|
||||||
|
|
||||||
|
if key == self.prefix .. 'RightWheel' then
|
||||||
|
self.rightWheel = val
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Differential:getInputs()
|
||||||
|
local inputs = {}
|
||||||
|
|
||||||
|
inputs[self.prefix .. 'LeftWheel'] = 'entity'
|
||||||
|
inputs[self.prefix .. 'RightWheel'] = 'entity'
|
||||||
|
|
||||||
|
return inputs
|
||||||
|
end
|
||||||
|
|
||||||
|
function Differential:getOutputs()
|
||||||
|
local outputs = {}
|
||||||
|
|
||||||
|
outputs[self.prefix .. 'LWAV'] = 'number'
|
||||||
|
outputs[self.prefix .. 'RWAV'] = 'number'
|
||||||
|
outputs[self.prefix .. 'AvgRPM'] = 'number'
|
||||||
|
outputs[self.prefix .. 'Test'] = 'number'
|
||||||
|
|
||||||
|
return outputs
|
||||||
|
end
|
||||||
|
|
||||||
|
function Differential:updateOutputs()
|
||||||
|
wire.ports[self.prefix .. 'LWAV'] = self.lwav
|
||||||
|
wire.ports[self.prefix .. 'RWAV'] = self.rwav
|
||||||
|
wire.ports[self.prefix .. 'AvgRPM'] = self.avgRPM
|
||||||
|
end
|
||||||
|
|
||||||
|
function Differential:linkGearbox(gbox)
|
||||||
|
self.gearbox = gbox
|
||||||
|
end
|
||||||
|
|
||||||
|
function Differential:getAngleVelocity()
|
||||||
|
local lwav = math.rad(self.leftWheel:getAngleVelocity()[2])
|
||||||
|
local rwav = math.rad(-self.rightWheel:getAngleVelocity()[2])
|
||||||
|
local awav = (lwav + rwav) / 2
|
||||||
|
|
||||||
|
return lwav, rwav, awav
|
||||||
|
end
|
||||||
|
|
||||||
|
function Differential:getRPM()
|
||||||
|
local lwav, rwav, awav = self:getAngleVelocity()
|
||||||
|
|
||||||
|
return lwav * RAD_TO_RPM, rwav * RAD_TO_RPM, awav * RAD_TO_RPM
|
||||||
|
end
|
||||||
|
|
||||||
|
function Differential:update()
|
||||||
|
if isValid(self.leftWheel) and isValid(self.rightWheel) then
|
||||||
|
local lwav, rwav = self:getAngleVelocity()
|
||||||
|
|
||||||
|
local inertia = self.leftWheel:getInertia().y + self.rightWheel:getInertia().y
|
||||||
|
local gboxTorque = self.gearbox and self.gearbox.torque or 0
|
||||||
|
local simmetric = gboxTorque * self.distributionCoeff * self.finalDrive / 2
|
||||||
|
local lock100 = (lwav - rwav) / 2 * inertia * TICK_INTERVAL
|
||||||
|
|
||||||
|
wire.ports[self.prefix .. 'Test'] = (gboxTorque * self.distributionCoeff * self.finalDrive) - ((simmetric - lock100) + (simmetric + lock100))
|
||||||
|
|
||||||
|
self.leftWheel:applyTorque((simmetric - lock100) * 1.33 * -self.leftWheel:getRight())
|
||||||
|
self.rightWheel:applyTorque((simmetric + lock100) * 1.33 * self.rightWheel:getRight())
|
||||||
|
|
||||||
|
self.lwav, self.rwav = self:getAngleVelocity()
|
||||||
|
_, _, self.avgRPM = self:getRPM()
|
||||||
|
self.avgRPM = self.avgRPM * self.finalDrive
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -3,16 +3,20 @@
|
|||||||
-- @include ./engine.txt
|
-- @include ./engine.txt
|
||||||
-- @include ./clutch.txt
|
-- @include ./clutch.txt
|
||||||
-- @include ./differential.txt
|
-- @include ./differential.txt
|
||||||
|
-- @include ./novojiloff_diff.txt
|
||||||
--
|
--
|
||||||
-- Helpers & stuff
|
-- Helpers & stuff
|
||||||
-- @include ./factories/gearbox.txt
|
-- @include ./factories/gearbox.txt
|
||||||
-- @include /koptilnya/libs/table.txt
|
-- @include /koptilnya/libs/table.txt
|
||||||
|
-- @include /koptilnya/libs/constants.txt
|
||||||
require('./engine.txt')
|
require('./engine.txt')
|
||||||
require('./clutch.txt')
|
require('./clutch.txt')
|
||||||
require('./differential.txt')
|
--require('./differential.txt')
|
||||||
|
require('./novojiloff_diff.txt')
|
||||||
require('./factories/gearbox.txt')
|
require('./factories/gearbox.txt')
|
||||||
|
|
||||||
require('/koptilnya/libs/table.txt')
|
require('/koptilnya/libs/table.txt')
|
||||||
|
require('/koptilnya/libs/constants.txt')
|
||||||
|
|
||||||
Vehicle = class('Vehicle')
|
Vehicle = class('Vehicle')
|
||||||
|
|
||||||
@ -36,11 +40,14 @@ function Vehicle:initialize(config)
|
|||||||
-- self.systems = table.map(config.Systems, function(config)
|
-- self.systems = table.map(config.Systems, function(config)
|
||||||
-- return SystemsFactory.create(config)
|
-- return SystemsFactory.create(config)
|
||||||
-- end)s
|
-- end)s
|
||||||
self.components = {self.clutch, self.engine, self.gearbox}
|
self.components = {self.clutch, self.gearbox}
|
||||||
self.components = table.add(self.components, self.axles)
|
self.components = table.add(self.components, self.axles)
|
||||||
|
self.components = table.add(self.components, {self.gearbox, self.clutch, self.engine})
|
||||||
-- self.components = table.add(self.components, self.systems)
|
-- self.components = table.add(self.components, self.systems)
|
||||||
|
|
||||||
local inputs = {}
|
local inputs = {
|
||||||
|
Base = "entity"
|
||||||
|
}
|
||||||
local outputs = {}
|
local outputs = {}
|
||||||
|
|
||||||
for _, comp in ipairs(self.components) do
|
for _, comp in ipairs(self.components) do
|
||||||
@ -51,11 +58,18 @@ function Vehicle:initialize(config)
|
|||||||
wire.adjustPorts(inputs, outputs)
|
wire.adjustPorts(inputs, outputs)
|
||||||
|
|
||||||
hook.add('tick', 'vehicle_update', function()
|
hook.add('tick', 'vehicle_update', function()
|
||||||
local outputs = {}
|
local base = wire.ports.Base
|
||||||
|
|
||||||
for _, comp in pairs(self.components) do
|
for _, comp in pairs(self.components) do
|
||||||
comp:update()
|
comp:update()
|
||||||
comp:updateOutputs()
|
comp:updateOutputs()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if isValid(base) and (self.clutch:getPress() == 1 or self.gearbox.ratio == 0) then
|
||||||
|
local tiltForce = self.engine.torque * (-1 + self.engine.masterThrottle * 2)
|
||||||
|
|
||||||
|
base:applyForceOffset(base:getUp() * tiltForce, base:getMassCenter() + base:getRight() * UNITS_PER_METER)
|
||||||
|
base:applyForceOffset(-base:getUp() * tiltForce, base:getMassCenter() - base:getRight() * UNITS_PER_METER)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,3 +4,5 @@ OWNER = owner()
|
|||||||
IS_ME = CURRENT_PLAYER == OWNER
|
IS_ME = CURRENT_PLAYER == OWNER
|
||||||
TICK_INTERVAL = game.getTickInterval()
|
TICK_INTERVAL = game.getTickInterval()
|
||||||
RAD_TO_RPM = 9.5493
|
RAD_TO_RPM = 9.5493
|
||||||
|
RPM_TO_RAD = 0.10472
|
||||||
|
UNITS_PER_METER = 39.37
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
-- @name koptilnya/libs/workers
|
-- @name koptilnya/libs/workers
|
||||||
|
|
||||||
WORKERS = {}
|
WORKERS = {}
|
||||||
WORKERS_QUOTA = 0.7
|
WORKERS_QUOTA = 0.5
|
||||||
|
|
||||||
local function canProcess()
|
local function canProcess()
|
||||||
local exp1 = (math.max(chip():getQuotaAverage(), chip():getQuotaUsed()) + (chip():getQuotaUsed() - math.max(chip():getQuotaAverage(), chip():getQuotaUsed())) * 0.01) / chip():getQuotaMax() < WORKERS_QUOTA
|
local exp1 = (math.max(quotaTotalAverage(), quotaTotalUsed()) + (quotaTotalUsed() - math.max(quotaTotalAverage(), quotaTotalUsed())) * 0.01) / quotaMax() < WORKERS_QUOTA
|
||||||
local exp2 = math.max(quotaTotalAverage(), quotaTotalUsed()) < quotaMax() * WORKERS_QUOTA
|
local exp2 = math.max(quotaTotalAverage(), quotaTotalUsed()) < quotaMax() * WORKERS_QUOTA
|
||||||
|
|
||||||
return exp1 and exp2
|
return exp1 and exp2
|
||||||
|
|||||||
@ -56,6 +56,8 @@ function MeshBuilder:initialize(link, modelPlaceholder)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MeshBuilder:_sendObjects(target)
|
function MeshBuilder:_sendObjects(target)
|
||||||
|
if not target then return end
|
||||||
|
if type(target) == "table" and #target == 0 then return end
|
||||||
if #self._objects == 0 then return end
|
if #self._objects == 0 then return end
|
||||||
|
|
||||||
net.start("objects")
|
net.start("objects")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user