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)