diff --git a/lua/entities/gmod_subway_81-501/init.lua b/lua/entities/gmod_subway_81-501/init.lua index 9f1645b..bb5a7f3 100644 --- a/lua/entities/gmod_subway_81-501/init.lua +++ b/lua/entities/gmod_subway_81-501/init.lua @@ -247,7 +247,7 @@ function ENT:Think() local TW18 = 0 if Panel.SSN > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end @@ -265,13 +265,6 @@ function ENT:Think() self:SetPackedBool("GRP",Panel.GreenRP > 0) self:SetPackedBool("BrY",Panel.BrY > 0) self:SetPackedBool("DoorsWC",Panel.DoorsWC > 0) - local TW18 = 0 - if Panel.SSN > 0 then - local wags = #self.WagonList - for _,v in ipairs(self.WagonList) do - TW18 = TW18+(v.Panel.TW18 or 0)/wags - end - end self:SetPackedRatio("RRP",math.Clamp(TW18^1.2,0,1)) self.TrueBrakeAngle = self.TrueBrakeAngle or 0 diff --git a/lua/entities/gmod_subway_81-502/init.lua b/lua/entities/gmod_subway_81-502/init.lua index 0d63d4a..7b5a1ad 100644 --- a/lua/entities/gmod_subway_81-502/init.lua +++ b/lua/entities/gmod_subway_81-502/init.lua @@ -275,7 +275,7 @@ function ENT:Think() local TW18 = 0 if Panel.SSN > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_81-702/init.lua b/lua/entities/gmod_subway_81-702/init.lua index 7f8a682..eb2428d 100644 --- a/lua/entities/gmod_subway_81-702/init.lua +++ b/lua/entities/gmod_subway_81-702/init.lua @@ -241,7 +241,7 @@ function ENT:Think() -- Red RP local TW18 = 0 if Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_81-702_int/init.lua b/lua/entities/gmod_subway_81-702_int/init.lua index b4f55c5..4de81f2 100644 --- a/lua/entities/gmod_subway_81-702_int/init.lua +++ b/lua/entities/gmod_subway_81-702_int/init.lua @@ -228,7 +228,7 @@ function ENT:Think() -- Red RP local TW18 = 0 if self.Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_81-703/init.lua b/lua/entities/gmod_subway_81-703/init.lua index 095ea65..a518ee0 100644 --- a/lua/entities/gmod_subway_81-703/init.lua +++ b/lua/entities/gmod_subway_81-703/init.lua @@ -248,7 +248,7 @@ function ENT:Think() -- Red RP local TW18 = 0 if Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_81-703_int/init.lua b/lua/entities/gmod_subway_81-703_int/init.lua index e4a4f81..6d3937a 100644 --- a/lua/entities/gmod_subway_81-703_int/init.lua +++ b/lua/entities/gmod_subway_81-703_int/init.lua @@ -240,7 +240,7 @@ function ENT:Think() -- Red RP local TW18 = 0 if Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_81-714_mvm/init.lua b/lua/entities/gmod_subway_81-714_mvm/init.lua index e444f6a..11b18b0 100644 --- a/lua/entities/gmod_subway_81-714_mvm/init.lua +++ b/lua/entities/gmod_subway_81-714_mvm/init.lua @@ -360,7 +360,7 @@ function ENT:Think() --10th wire voltage readout imitation depending on the BPSNs and EKK state, not on the wagon battery switch state local hvcounter = 0 local hvcar = nil - local vdrop = 1.125*(#self.WagonList) + local vdrop = 1.125*(self.WagonCount) for k,v in ipairs(self.WagonList) do if v.PowerSupply.X2_2 > 0 and v.A24.Value > 0 then hvcounter = hvcounter + 1 @@ -372,9 +372,9 @@ function ENT:Think() end local PCV_o = hvcounter > 0 and math.Clamp(76+(hvcar.Electric.Aux750V - 600)*8/375, 76, 84) - vdrop or self.WagonList[1].Battery.Voltage --imitating converter overload protection only when control circuits are energized and at least one PC on the train is off; pretty useless btw (but fun) - local pcloadratio = #self.WagonList/(hvcounter > 0 and hvcounter or 0.5) + local pcloadratio = self.WagonCount/(hvcounter > 0 and hvcounter or 0.5) local _A = 25*(6 - 6/(5.01)) --assuming one PC on 6 cars can work for 25 secs while the cars' CCs are energized - if pcloadratio > 1 and pcloadratio <= #self.WagonList and self.LK4.Value > 0 and self.PowerSupply.X2_2 > 0 and not self.pcrlxtimer then + if pcloadratio > 1 and (pcloadratio <= self.WagonCount) and self.LK4.Value > 0 and self.PowerSupply.X2_2 > 0 and not self.pcrlxtimer then self.pcprotimer = self.pcprotimer or CurTime() --hyperbolic function of PC operating time depending on load coeff if CurTime() - self.pcprotimer > _A/(pcloadratio - 6/5.01) then diff --git a/lua/entities/gmod_subway_81-717_lvz/init.lua b/lua/entities/gmod_subway_81-717_lvz/init.lua index 9c0de18..7cec0a0 100644 --- a/lua/entities/gmod_subway_81-717_lvz/init.lua +++ b/lua/entities/gmod_subway_81-717_lvz/init.lua @@ -596,7 +596,7 @@ function ENT:Think() -- Red RP local TW18 = 0 if Panel.LSN > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for i,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_81-717_mvm/init.lua b/lua/entities/gmod_subway_81-717_mvm/init.lua index 3ed1da5..e5b6fd1 100644 --- a/lua/entities/gmod_subway_81-717_mvm/init.lua +++ b/lua/entities/gmod_subway_81-717_mvm/init.lua @@ -621,7 +621,7 @@ function ENT:Think() -- Red RP local TW18 = 0 if Panel.LSN > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for i,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end @@ -681,7 +681,7 @@ function ENT:Think() -- PC — power converter; CC — control circuits local hvcounter = 0 local hvcar = nil - local vdrop = 1.125*(#self.WagonList) + local vdrop = 1.125*(self.WagonCount) for k,v in ipairs(self.WagonList) do if v.PowerSupply.X2_2 > 0 and v.A24.Value > 0 then hvcounter = hvcounter + 1 @@ -693,9 +693,9 @@ function ENT:Think() end local PCV_o = hvcounter > 0 and math.Clamp(76+(hvcar.Electric.Aux750V - 600)*8/375, 76, 84) - vdrop or self.WagonList[1].Battery.Voltage --imitating converter overload protection only when control circuits are energized and at least one PC on the train is off; pretty useless btw (but fun) - local pcloadratio = #self.WagonList/(hvcounter > 0 and hvcounter or 0.5) + local pcloadratio = self.WagonCount/(hvcounter > 0 and hvcounter or 0.5) local _A = 25*(6 - 6/(5.01)) --assuming one PC on 6 cars can work for 25 secs while the cars' CCs are energized - if pcloadratio > 1 and pcloadratio <= #self.WagonList and self.LK4.Value > 0 and self.PowerSupply.X2_2 > 0 and not self.pcrlxtimer then + if pcloadratio > 1 and (pcloadratio <= self.WagonCount) and self.LK4.Value > 0 and self.PowerSupply.X2_2 > 0 and not self.pcrlxtimer then self.pcprotimer = self.pcprotimer or CurTime() --hyperbolic function of PC operating time depending on load coeff if CurTime() - self.pcprotimer > _A/(pcloadratio - 6/5.01) then diff --git a/lua/entities/gmod_subway_81-718/init.lua b/lua/entities/gmod_subway_81-718/init.lua index 8a08ad8..02f21a2 100644 --- a/lua/entities/gmod_subway_81-718/init.lua +++ b/lua/entities/gmod_subway_81-718/init.lua @@ -511,7 +511,7 @@ function ENT:Think() self:SetPackedBool("HL25",Panel.HL25 > 0) local TW28 = 0 if Panel.HL6 > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for i,v in ipairs(self.WagonList) do TW28 = TW28+(v.Panel.TW28 or 0)/wags end diff --git a/lua/entities/gmod_subway_81-722/init.lua b/lua/entities/gmod_subway_81-722/init.lua index b28ec1d..ba36459 100644 --- a/lua/entities/gmod_subway_81-722/init.lua +++ b/lua/entities/gmod_subway_81-722/init.lua @@ -217,14 +217,14 @@ function ENT:Think() --[[ if self:GetWagonNumber() == 22010 or self:EntIndex()==1560 then --DEBUG local accel = 0 - for i=1,#self.WagonList do + for i=1,self.WagonCount do accel=accel+self.WagonList[i].Acceleration end local drivers = {self.DriverSeat,self.InstructorsSeat,self.ExtraSeat1,self.ExtraSeat2} if math.abs(accel) > 0.1 then for k,v in pairs(drivers) do if IsValid(v) and IsValid(v:GetDriver()) then - v:GetDriver():ChatPrint(Format("v=%.2f I=%.2f RK=%02d a=%.2f",self.Speed,0 or (self.Electric.I13+self.Electric.I24)/2,0 or self.RheostatController.SelectedPosition or 0,accel/#self.WagonList))--(accel/#self.WagonList))) + v:GetDriver():ChatPrint(Format("v=%.2f I=%.2f RK=%02d a=%.2f",self.Speed,0 or (self.Electric.I13+self.Electric.I24)/2,0 or self.RheostatController.SelectedPosition or 0,accel/self.WagonCount))--(accel/self.WagonCount))) end end end diff --git a/lua/entities/gmod_subway_base/init.lua b/lua/entities/gmod_subway_base/init.lua index f04e6cd..a240994 100644 --- a/lua/entities/gmod_subway_base/init.lua +++ b/lua/entities/gmod_subway_base/init.lua @@ -475,7 +475,7 @@ function ENT:InitializeHighspeedLayout() end function ENT:ChooseTrainWireLeader() - local key = math.random( 1, #self.WagonList ) + local key = math.random( 1, self.WagonCount ) for k,v in ipairs(self.WagonList) do v.TrainWireLeader = key==k end @@ -548,6 +548,7 @@ function ENT:UpdateWagonList(selfupdate) end end populateList(self,{}) + self.WagonCount = #self.WagonList if selfupdate then return end for _,v in pairs(self.WagonList) do if v ~= self then v:UpdateWagonList(true) end @@ -555,7 +556,7 @@ function ENT:UpdateWagonList(selfupdate) end function ENT:GetWagonCount() - return #self.WagonList + return self.WagonCount end function ENT:ReadCell(Address) @@ -688,7 +689,7 @@ function ENT:ReadCell(Address) end if Address == 65535 then ---self:UpdateWagonList() - return #self.WagonList + return self.WagonCount end if Address >= 65536 then local wagonIndex = 1+math.floor(Address/65536) @@ -774,7 +775,7 @@ function ENT:SpawnSwitch(model,pos,ang,min,max,soundtbl) end function ENT:CANWrite(source,sourceid,target,targetid,textdata,numdata,checked) - for i=1,#self.WagonList do + for i=1,self.WagonCount do local train = self.WagonList[i] if not targetid or targetid == train:GetWagonNumber() then local sys = train[target] @@ -857,7 +858,7 @@ function ENT:GetTrainWire18() -- Mask for panel RP light info --local Mask = (self.Panel["RedRP"] > 0.25) and 0 or 1e9 - return Rtotal/#self.WagonList + return Rtotal/self.WagonCount end @@ -1867,7 +1868,7 @@ function ENT:Think() if v > 0 then writeTrainWire(self,k,v,true) end end--]] if self.TrainWireLeader then - if #self.WagonList == 1 then + if self.WagonCount == 1 then for twID in pairs(self.TrainWireWritersID) do self.TrainWires[twID] = self:LeaderReadTrainWire(twID) end @@ -1898,7 +1899,7 @@ function ENT:Think() end end end - local TrainCount = #self.WagonList + local TrainCount = self.WagonCount for i,train in ipairs(self.WagonList) do local inv = train.TrainCoupledIndex ~= self.TrainCoupledIndex for twID in pairs(wires) do @@ -2522,7 +2523,7 @@ end if math.abs(accel) > 0.1 then for k,v in pairs(drivers) do if IsValid(v) and IsValid(v:GetDriver()) then - v:GetDriver():ChatPrint(Format("v=%.2f I=%.2f RK=%02d a=%.2f",self.Speed,(self.Electric.I13+self.Electric.I24)/2,self.RheostatController.SelectedPosition or 0,accel/#self.WagonList))--(accel/#self.WagonList))) + v:GetDriver():ChatPrint(Format("v=%.2f I=%.2f RK=%02d a=%.2f",self.Speed,(self.Electric.I13+self.Electric.I24)/2,self.RheostatController.SelectedPosition or 0,accel/self.WagonCount))--(accel/self.WagonCount))) end end end @@ -2551,7 +2552,7 @@ end if math.abs(accel) > 0.1 then for k,v in pairs(drivers) do if IsValid(v) and IsValid(v:GetDriver()) then - v:GetDriver():ChatPrint(Format("v=%.2f I=%.2f RK=%02d a=%.2f",self.Speed,(self.Electric.I13+self.Electric.I24)/2,self.RheostatController.SelectedPosition or 0,accel/#self.WagonList))--(accel/#self.WagonList))) + v:GetDriver():ChatPrint(Format("v=%.2f I=%.2f RK=%02d a=%.2f",self.Speed,(self.Electric.I13+self.Electric.I24)/2,self.RheostatController.SelectedPosition or 0,accel/self.WagonCount))--(accel/self.WagonCount))) end end end @@ -2598,9 +2599,9 @@ end end if math.abs(accel) > 0.1 then - Player(6):ChatPrint(Format("v=%.2f I=%.2f",self.Speed,(accel/#self.WagonList))) - Player(7):ChatPrint(Format("v=%.2f I=%.2f",self.Speed,(accel/#self.WagonList))) - Player(9):ChatPrint(Format("v=%.2f I=%.2f",self.Speed,(accel/#self.WagonList))) + Player(6):ChatPrint(Format("v=%.2f I=%.2f",self.Speed,(accel/self.WagonCount))) + Player(7):ChatPrint(Format("v=%.2f I=%.2f",self.Speed,(accel/self.WagonCount))) + Player(9):ChatPrint(Format("v=%.2f I=%.2f",self.Speed,(accel/self.WagonCount))) end end--]] diff --git a/lua/entities/gmod_subway_em508/init.lua b/lua/entities/gmod_subway_em508/init.lua index d74e304..c9f46e7 100644 --- a/lua/entities/gmod_subway_em508/init.lua +++ b/lua/entities/gmod_subway_em508/init.lua @@ -241,7 +241,7 @@ function ENT:Think() local TW18 = 0 if Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_em508t/init.lua b/lua/entities/gmod_subway_em508t/init.lua index 9efa7a8..5bdad97 100644 --- a/lua/entities/gmod_subway_em508t/init.lua +++ b/lua/entities/gmod_subway_em508t/init.lua @@ -238,7 +238,7 @@ function ENT:Think() local TW18 = 0 if Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_em509/init.lua b/lua/entities/gmod_subway_em509/init.lua index 08704ce..4dcaab7 100644 --- a/lua/entities/gmod_subway_em509/init.lua +++ b/lua/entities/gmod_subway_em509/init.lua @@ -275,7 +275,7 @@ function ENT:Think() -- Red RP local TW18 = 0 if Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_ezh/init.lua b/lua/entities/gmod_subway_ezh/init.lua index 8e725f5..414984f 100644 --- a/lua/entities/gmod_subway_ezh/init.lua +++ b/lua/entities/gmod_subway_ezh/init.lua @@ -291,7 +291,7 @@ function ENT:Think() local TW18 = 0 if Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_ezh1/init.lua b/lua/entities/gmod_subway_ezh1/init.lua index ecfa69b..d981481 100644 --- a/lua/entities/gmod_subway_ezh1/init.lua +++ b/lua/entities/gmod_subway_ezh1/init.lua @@ -240,7 +240,7 @@ function ENT:Think() local TW18 = 0 if Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/entities/gmod_subway_ezh3/init.lua b/lua/entities/gmod_subway_ezh3/init.lua index 3c8342b..0bbafc7 100644 --- a/lua/entities/gmod_subway_ezh3/init.lua +++ b/lua/entities/gmod_subway_ezh3/init.lua @@ -288,7 +288,7 @@ function ENT:Think() local TW18 = 0 if Panel.RRP > 0 then - local wags = #self.WagonList + local wags = self.WagonCount for _,v in ipairs(self.WagonList) do TW18 = TW18+(v.Panel.TW18 or 0)/wags end diff --git a/lua/metrostroi/systems/sys_81_71_announcer.lua b/lua/metrostroi/systems/sys_81_71_announcer.lua index e998905..aadb2aa 100644 --- a/lua/metrostroi/systems/sys_81_71_announcer.lua +++ b/lua/metrostroi/systems/sys_81_71_announcer.lua @@ -37,8 +37,9 @@ if SERVER then function TRAIN_SYSTEM:Queue(tbl) if not Metrostroi[self.AnnTable] then return end + local Train = self.Train for k, v in pairs(tbl) do - local tbl = Metrostroi[self.AnnTable][self.Train:GetNW2Int("Announcer", 1)] or Metrostroi[self.AnnTable][1] + local tbl = Metrostroi[self.AnnTable][Train:GetNW2Int("Announcer", 1)] or Metrostroi[self.AnnTable][1] if v~=-2 then table.insert(self.Schedule, tbl and tbl[v] or v) else @@ -56,10 +57,10 @@ if SERVER then self:WriteMessage("_STOP") end function TRAIN_SYSTEM:WriteMessage(msg) - for i = 1, #self.Train.WagonList do + local Train = self.Train + for i=1,Train.WagonCount do net.Start("metrostroi_announcer", true) - local train = self.Train.WagonList[i] - net.WriteEntity(train) + net.WriteEntity(Train.WagonList[i]) net.WriteString(msg) net.WriteString(self.AnnTable) net.Broadcast() @@ -68,16 +69,15 @@ if SERVER then --end function TRAIN_SYSTEM:Think() + local Train = self.Train if #self.Schedule > 0 and not self.Playing then - for i = 1, #self.Train.WagonList do - local train = self.Train.WagonList[i] - train:SetNW2Bool("AnnouncerPlaying", true) + for i=1,Train.WagonCount do + Train.WagonList[i]:SetNW2Bool("AnnouncerPlaying", true) end self.Playing = true elseif #self.Schedule == 0 and self.Playing and not self.AnnounceTimer then - for i = 1, #self.Train.WagonList do - local train = self.Train.WagonList[i] - train:SetNW2Bool("AnnouncerPlaying", false) + for i=1,Train.WagonCount do + Train.WagonList[i]:SetNW2Bool("AnnouncerPlaying", false) end self.Playing = false end @@ -86,19 +86,18 @@ if SERVER then local tbl = table.remove(self.Schedule, 1) if type(tbl) == "number" then if tbl == -1 then - for i = 1, #self.Train.WagonList do - local train = self.Train.WagonList[i] - train.AnnouncementToLeaveWagon = true + for i=1,Train.WagonCount do + Train.WagonList[i].AnnouncementToLeaveWagon = true --train.AnnouncementToLeaveWagonAcknowledged = false end elseif self.NoiseWork == true then self.NoiseWork = tbl - for i = 1, #self.Train.WagonList do - self.Train.WagonList[i]:SetNW2Int("AnnouncerNoise", tbl) + for i=1,Train.WagonCount do + Train.WagonList[i]:SetNW2Int("AnnouncerNoise", tbl) end elseif self.BuzzWork == 1 then - for i = 1, #self.Train.WagonList do - self.Train.WagonList[i]:SetNW2Int("AnnouncerBuzz", tbl) + for i=1,Train.WagonCount do + Train.WagonList[i]:SetNW2Int("AnnouncerBuzz", tbl) end self.BuzzWork = true else @@ -107,25 +106,25 @@ if SERVER then elseif tbl == "noise_start" then self.NoiseWork = true elseif tbl == "noise_end" then - for i = 1, #self.Train.WagonList do - self.Train.WagonList[i]:SetNW2Int("AnnouncerNoise", -1) + for i=1,Train.WagonCount do + Train.WagonList[i]:SetNW2Int("AnnouncerNoise", -1) end self.NoiseWork = false elseif tbl == "buzz_start_upo" then self.BuzzWork = 1 elseif tbl == "buzz_end_upo" then - for i = 1, #self.Train.WagonList do - self.Train.WagonList[i]:SetNW2Int("AnnouncerBuzz", -1) + for i=1,Train.WagonCount do + Train.WagonList[i]:SetNW2Int("AnnouncerBuzz", -1) end elseif tbl == "buzz_start" then - local bpsn = self.Train:GetNW2Int("BPSNType",13) - for i = 1, #self.Train.WagonList do - self.Train.WagonList[i]:SetNW2Int("AnnouncerBuzz", (bpsn == 1 or bpsn == 2 or bpsn == 8) and 2 or 1) + local bpsn = Train:GetNW2Int("BPSNType",13) + for i=1,Train.WagonCount do + Train.WagonList[i]:SetNW2Int("AnnouncerBuzz", (bpsn == 1 or bpsn == 2 or bpsn == 8) and 2 or 1) end self.BuzzWork = true elseif tbl == "buzz_end" then - for i = 1, #self.Train.WagonList do - self.Train.WagonList[i]:SetNW2Int("AnnouncerBuzz", -1) + for i=1,Train.WagonCount do + Train.WagonList[i]:SetNW2Int("AnnouncerBuzz", -1) end self.BuzzWork = false elseif type(tbl) == "table" then diff --git a/lua/metrostroi/systems/sys_81_720_buv.lua b/lua/metrostroi/systems/sys_81_720_buv.lua index e745dfa..876e67c 100644 --- a/lua/metrostroi/systems/sys_81_720_buv.lua +++ b/lua/metrostroi/systems/sys_81_720_buv.lua @@ -120,7 +120,6 @@ function TRAIN_SYSTEM:Think() self.CurTime = CurTime() local Train = self.Train - local wagcount = #Train.WagonList self.Power = Train.Electric.Battery80V > 62 and 1 or 0 self.State = self.Power > 0 and Train.SFV2.Value > 0.5 diff --git a/lua/metrostroi/systems/sys_81_720_pneumatic.lua b/lua/metrostroi/systems/sys_81_720_pneumatic.lua index 9ba8987..dc5d941 100644 --- a/lua/metrostroi/systems/sys_81_720_pneumatic.lua +++ b/lua/metrostroi/systems/sys_81_720_pneumatic.lua @@ -346,7 +346,7 @@ function TRAIN_SYSTEM:Think(dT) local count = 0 local command = 0 --[[ - for i=1,#Train.WagonList do + for i=1,Train.WagonCount do local train = Train.WagonList[i] if train.BUKP then if train.BUKP.Loop == 0 then diff --git a/lua/metrostroi/systems/sys_81_722_bukv.lua b/lua/metrostroi/systems/sys_81_722_bukv.lua index c1e52f4..7e7ece7 100644 --- a/lua/metrostroi/systems/sys_81_722_bukv.lua +++ b/lua/metrostroi/systems/sys_81_722_bukv.lua @@ -75,7 +75,6 @@ function TRAIN_SYSTEM:Think() self.CurTime = CurTime() local Train = self.Train - local wagcount = #Train.WagonList self.Power = Train.Electric.Power self.State = self.Power > 0 and Train.SF51.Value > 0.5 self.TrainIndex = Train:GetWagonNumber() diff --git a/lua/metrostroi/systems/sys_81_722_pneumatic.lua b/lua/metrostroi/systems/sys_81_722_pneumatic.lua index 8dcc6ff..3af2e89 100644 --- a/lua/metrostroi/systems/sys_81_722_pneumatic.lua +++ b/lua/metrostroi/systems/sys_81_722_pneumatic.lua @@ -350,7 +350,7 @@ function TRAIN_SYSTEM:Think(dT) local leak = 0]]--[[ local count = 0 local command = 0 - for i=1,#Train.WagonList do + for i=1,Train.WagonCount do local train = Train.WagonList[i] if train.BUKP then if train.BUKP.Loop == 0 then