From 38688cc83a5bdd700225f00c93b9361aa150ce64 Mon Sep 17 00:00:00 2001 From: ZONT_ Date: Thu, 30 Apr 2026 01:41:28 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D1=81=D1=86?= =?UTF-8?q?=D0=B5=D0=BF=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=BF?= =?UTF-8?q?=D0=B0=D0=B2=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/entities/gmod_train_couple/init.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/entities/gmod_train_couple/init.lua b/lua/entities/gmod_train_couple/init.lua index 84f8316..bda2a4c 100644 --- a/lua/entities/gmod_train_couple/init.lua +++ b/lua/entities/gmod_train_couple/init.lua @@ -313,7 +313,18 @@ function ENT:OnDecouple() end end +local vector_zero = Vector(0, 0, 0) function ENT:Think() - self:NextThink(CurTime()+1) + local train = self:GetNW2Entity("TrainEntity") + if IsValid(train) and train.OnCoupled and not IsValid(self.Coupled) then + -- Fixing crazy physics on spawn + local phy = self:GetPhysicsObject() + if IsValid(phy) then + phy:SetAngleVelocityInstantaneous(vector_zero) + end + self:NextThink(CurTime()) + else + self:NextThink(CurTime() + 1) + end return true end From db63831dde4ca1a840c39dc89b94547228e13302 Mon Sep 17 00:00:00 2001 From: ZONT_ Date: Thu, 30 Apr 2026 02:56:19 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D1=84=D0=B8=D0=BA=D1=81=D0=B0=20?= =?UTF-8?q?=D1=81=D1=86=D0=B5=D0=BF=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/entities/gmod_train_couple/init.lua | 3 +-- lua/weapons/gmod_tool/stools/train_spawner.lua | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/entities/gmod_train_couple/init.lua b/lua/entities/gmod_train_couple/init.lua index bda2a4c..8c8a4e8 100644 --- a/lua/entities/gmod_train_couple/init.lua +++ b/lua/entities/gmod_train_couple/init.lua @@ -315,8 +315,7 @@ end local vector_zero = Vector(0, 0, 0) function ENT:Think() - local train = self:GetNW2Entity("TrainEntity") - if IsValid(train) and train.OnCoupled and not IsValid(self.Coupled) then + if self.TrainSpawnerCoupleFix then -- Fixing crazy physics on spawn local phy = self:GetPhysicsObject() if IsValid(phy) then diff --git a/lua/weapons/gmod_tool/stools/train_spawner.lua b/lua/weapons/gmod_tool/stools/train_spawner.lua index b6a699d..ef3ed70 100644 --- a/lua/weapons/gmod_tool/stools/train_spawner.lua +++ b/lua/weapons/gmod_tool/stools/train_spawner.lua @@ -327,6 +327,12 @@ function TOOL:SpawnWagon(trace) ent:UpdateTextures() ent.FrontAutoCouple = i > 1 and i < self.Settings.WagNum ent.RearAutoCouple = self.Settings.WagNum > 1 + if IsValid(ent.FrontCouple) then + ent.FrontCouple.TrainSpawnerCoupleFix = ent.FrontAutoCouple + end + if IsValid(ent.RearCouple) then + ent.RearCouple.TrainSpawnerCoupleFix = ent.RearAutoCouple + end LastEnt = ent end undo.SetPlayer(ply) @@ -342,6 +348,8 @@ function TOOL:SpawnWagon(trace) train.RearBogey.BrakeCylinderPressure = 3 train.FrontBogey.MotorPower = 0 train.RearBogey.MotorPower = 0 + train.FrontCouple.TrainSpawnerCoupleFix = nil + train.RearCouple.TrainSpawnerCoupleFix = nil train.OnCoupled = nil end timer.Simple(1,function() for i,train in ipairs(trains) do train.IgnoreEngine = false end end)