1
0
mirror of https://github.com/metrostroi-repo/MetrostroiAddon.git synced 2026-05-02 00:42:29 +00:00
Resolved #462 #461 #459 #449
This commit is contained in:
Ilya Krasnow
2022-04-09 23:32:23 +03:00
parent 2bbb67ff9a
commit 1b00a60d7a
8 changed files with 344 additions and 331 deletions

View File

@@ -89,7 +89,7 @@ function TRAIN_SYSTEM:SolveAllInternalCircuits(Train,dT,firstIter)
--RRI_VV.CabinSpeakerPower = T[13]
else
local ASNP_VV = Train.ASNP_VV
ASNP_VV.Power = BO*Train.R_Radio.Value*Train.R_ASNPOn.Value
ASNP_VV.Power = BO*Train.R_ASNPOn.Value
ASNP_VV.AmplifierPower = ASNP_VV.Power*Train.ASNP.LineOut*Train.R_UNch.Value
ASNP_VV.CabinSpeakerPower = ASNP_VV.Power*Train.ASNP.LineOut*Train.R_G.Value
Train:WriteTrainWire(13,ASNP_VV.AmplifierPower)

View File

@@ -18,6 +18,8 @@ function TRAIN_SYSTEM:Initialize()
"R_Program2",
"R_Program1H",
"R_Program2H",
"R_ASNPPath",
"R_Radio"
--R_Announcer
--R_Line
}
@@ -39,6 +41,7 @@ function TRAIN_SYSTEM:Initialize()
self.Train:LoadSystem("R_ASNPMenu","Relay","Switch",{bass = true })
self.Train:LoadSystem("R_ASNPUp","Relay","Switch",{bass = true })
self.Train:LoadSystem("R_ASNPDown","Relay","Switch",{bass = true })
self.Train:LoadSystem("R_ASNPPath","Relay","Switch",{normally_closed = false, bass = true })
end
self.K1 = 0
self.K2 = 0
@@ -150,17 +153,11 @@ if CLIENT then
return
end
if State == 2 then
local RouteNumber = Format("%02d",Train:GetNW2Int("ASNP:RouteNumber",0))
local RouteNumber = Format("%2d",Train:GetNW2Int("ASNP:RouteNumber",0))
local sel = Train:GetNW2Int("ASNP:Selected",0)
self:PrintText(0,0,"Номер маршрута:")
if sel == 2 then
self:PrintText(4,1,"\"+-\" отм \"MENU\" ввод")
else
self:PrintText(4,1,"\"+-\" выб \"MENU\" след")
end
self:PrintText(0,0,"Выбор N маршрута")
if sel~=0 or RealTime()%1 > 0.5 then self:PrintText(0,1,RouteNumber[1]) end
if sel~=1 or RealTime()%1 > 0.5 then self:PrintText(1,1,RouteNumber[2]) end
self:PrintText(0,1,RouteNumber)
end
local stbl = Metrostroi.ASNPSetup and Metrostroi.ASNPSetup[Train:GetNW2Int("Announcer",1)]
@@ -174,17 +171,18 @@ if CLIENT then
local Line = self.Train:GetNW2Int("ASNP:Line",1)
local ltbl = stbl[Line]
local St,En = ltbl[1],ltbl[#ltbl]
self:PrintText(0,0,ltbl.Loop and "Маршрут (кол)" or "Маршрут")
self:PrintText(20,0,"-")
if RealTime()%0.8 > 0.4 then
self:PrintText(17,0,Format("%03d",St[1]))
self:PrintText(21,0,Format("%03d",En[1]))
end
local timer = math.ceil(RealTime()%6/1.5)
if timer == 1 then self:PrintText(0,1,(ltbl.Name or "Нет названия"))
elseif timer == 2 then self:PrintText(0,1,"От:") self:PrintText(3,1,St[2])
elseif timer == 3 then self:PrintText(0,1,"До:") self:PrintText(3,1,En[2])
elseif timer == 4 then self:PrintText(0,1,"\"+-\" выбор \"MENU\" ввод") end
self:PrintText(0,0,ltbl.Loop and "Выбор линии (кол)" or "Выбор линии -")
-- self:PrintText(20,0,"-")
-- if RealTime()%0.8 > 0.4 then
-- self:PrintText(17,0,Format("%03d",St[1]))
-- self:PrintText(21,0,Format("%03d",En[1]))
-- end
-- local timer = math.ceil(RealTime()%6/1.5)
self:PrintText(0,1,(ltbl.Name or "Нет названия"))
-- if timer == 1 then self:PrintText(0,1,(ltbl.Name or "Нет названия"))
-- elseif timer == 2 then self:PrintText(0,1,"От:") self:PrintText(3,1,St[2])
-- elseif timer == 3 then self:PrintText(0,1,"До:") self:PrintText(3,1,En[2])
-- elseif timer == 4 then self:PrintText(0,1,"\"+-\" выбор \"MENU\" ввод") end
end
if State == 4 then
@@ -198,13 +196,9 @@ if CLIENT then
if RealTime()%0.8 > 0.4 then self:PrintText(18,0,Train:GetNW2Bool("ASNP:Path") and "II" or "I") end
self:PrintText(20,0,"-")
else
local St = ltbl[Train:GetNW2Int("ASNP:FirstStation",1)]
self:PrintText(0,0,"Начальная ст.")
self:PrintText(0,1,St[1]..":"..St[2])
self:PrintText(20,0,"-")
if RealTime()%0.8 > 0.4 then
self:PrintText(17,0,Format("%03d",St[1]))
end
local St = ltbl[Train:GetNW2Int("ASNP:Station",1)]
self:PrintText(0,0,"Текущая станция -")
self:PrintText(0,1,St[2])
end
end
@@ -214,7 +208,7 @@ if CLIENT then
if ltbl.Loop then
local station = Train:GetNW2Int("ASNP:LastStation",1)
local En = ltbl[station]
self:PrintText(0,0,"Конечная ст.")
self:PrintText(0,0,"Конечная станция ")
if station == 0 then
self:PrintText(0,1," ():".."Кольцевой")
else
@@ -222,56 +216,33 @@ if CLIENT then
end
local Path = Train:GetNW2Bool("ASNP:Path") and "II" or "I"
self:PrintText(18,0,Path)
self:PrintText(20,0,"-")
if RealTime()%0.8 > 0.4 then
if En then
self:PrintText(21,0,Format("%03d",En[1]))
else
self:PrintText(22,0,Path)
end
end
-- self:PrintText(20,0,"-")
-- if RealTime()%0.8 > 0.4 then
-- if En then
-- self:PrintText(21,0,Format("%03d",En[1]))
-- else
-- self:PrintText(22,0,Path)
-- end
-- end
else
local St = ltbl[Train:GetNW2Int("ASNP:FirstStation",1)]
local En = ltbl[Train:GetNW2Int("ASNP:LastStation",1)]
self:PrintText(0,0,"Конечная станция")
self:PrintText(0,1,En[1]..":"..En[2])
self:PrintText(20,0,"-")
self:PrintText(17,0,Format("%03d",St[1]))
if RealTime()%0.8 > 0.4 then
self:PrintText(21,0,Format("%03d",En[1]))
end
self:PrintText(0,0,"Выбор ст. оборота -")
self:PrintText(0,1,En[2])
-- self:PrintText(20,0,"-")
-- self:PrintText(17,0,Format("%03d",St[1]))
-- if RealTime()%0.8 > 0.4 then
-- self:PrintText(21,0,Format("%03d",En[1]))
-- end
end
end
if State == 6 then
local Line = Train:GetNW2Int("ASNP:Line",1)
local ltbl = stbl[Line]
local Path = Train:GetNW2Bool("ASNP:Path")
self:PrintText(0,0,"Проверьте данные")
self:PrintText(17,0,Format("%02d",Line))
self:PrintText(20,0,Format("%02d",Train:GetNW2Int("ASNP:RouteNumber",0)))
self:PrintText(23,0,Path and "II" or "I")
if ltbl.Loop then
local station = Train:GetNW2Int("ASNP:LastStation",1)
local En = ltbl[station]
--self:PrintText(20,0,"()")
local timer = math.ceil(RealTime()%4.5/1.5)
if timer == 1 then self:PrintText(0,1,"(кол) "..(ltbl.Name or "Нет названия"))
elseif timer == 2 and station > 0 then self:PrintText(0,1,"До:");self:PrintText(3,1,En[2]);self:PrintText(21,1,tostring(En[1]))
elseif timer == 2 and station == 0 then self:PrintText(0,1,"Без конечной")
elseif timer == 3 then self:PrintText(0,1,"\"+-\" отмена \"MENU\" ок") end
else
local St = ltbl[Train:GetNW2Int("ASNP:FirstStation",1)]
local En = ltbl[Train:GetNW2Int("ASNP:LastStation",1)]
if Path then
local StT = En;En=St;St=StT
end
local timer = math.ceil(RealTime()%6/1.5)
if timer == 1 then self:PrintText(0,1,(ltbl.Name or "Нет названия"))
elseif timer == 2 then self:PrintText(0,1,"От:");self:PrintText(3,1,St[2]);self:PrintText(21,1,tostring(St[1]))
elseif timer == 3 then self:PrintText(0,1,"До:");self:PrintText(3,1,En[2]);self:PrintText(21,1,tostring(En[1]))
elseif timer == 4 then self:PrintText(0,1,"\"+-\" выб \"MENU\" ввод") end
end
local Arrived = Train:GetNW2Bool("ASNP:Arrived")
self:PrintText(0,0,"Выбор приб / отпр")
self:PrintText(0,1,Arrived and "Отпр." or "Приб.")
end
if State == 7 then
local Line = Train:GetNW2Int("ASNP:Line",1)
@@ -295,18 +266,19 @@ if CLIENT then
if Dep then self:PrintText(0,0,"Отпр.") else self:PrintText(0,0,"Приб.") end
self:PrintText(6,0,Station[2])
if Train:GetNW2Bool("ASNP:Playing",false) then
self:PrintText(0,1,"<<< ИДЕТ ОБЪЯВЛЕНИЕ >>>")
self:PrintText(0,1,"<<< ИДЕТ ОБЪЯВЛЕНИЕ >>>")
--elseif Station == En then
-- self:PrintText(0,1,"<<< КОНЕЧАЯ >>>")
else
--self:PrintText(0,1,string.rep("I",Path and 2 or 1))
if Path then
local ezh = Train.SubwayTrain.Name:find("zh")
if not ezh and Path then
self:PrintText(-0.2,1,"I")
self:PrintText( 0.2,1,"I")
else
elseif not ezh then
self:PrintText(0,1,"I")
end
self:PrintText(2,1,string.format("% 2d.",Train:GetNW2Int("ASNP:RouteNumber",0)))
self:PrintText(ezh and 0 or 2,1,string.format("%2d",Train:GetNW2Int("ASNP:RouteNumber",0)))
if ltbl.Loop and Train:GetNW2Int("ASNP:LastStation",1) == 0 then
self:PrintText(6,1,"Кольцевой")
else
@@ -512,7 +484,21 @@ end
function TRAIN_SYSTEM:Trigger(name,value)
local tbl = Metrostroi.ASNPSetup[self.Train:GetNW2Int("Announcer",1)]
if (name == "R_Program2" or name == "R_Program2H") and value then
if name=="R_ASNPPath" then
self.Train.Announcer:Reset()
self.Path = value
self.Arrived = true
self.FirstStation = 1
self.LastStation = self.Path and 1 or #tbl[self.Line]
self.Station = self.Path and #tbl[self.Line] or 1
self.PlayNextArmed = false
return
end
if name:find("R_ASNP") then
self.TriggerButton = value and false or name
self.TriggerButtonTime = value and false or CurTime()
end
if (not self.Train.R_Radio or self.Train.R_Radio.Value>0) and (name == "R_Program2" or name == "R_Program2H") and value then
if self.State ~= 7 and tbl[self.Line] and tbl[self.Line].spec_last then
if self.LineOut>0 then self:AnnQueue{-2,"buzz_end","click2"} end
self:AnnQueue{"click1","buzz_start"}
@@ -556,21 +542,22 @@ function TRAIN_SYSTEM:Trigger(name,value)
end
end
end
if name == "R_Radio" and not value and self.LineOut>0 then
self.Train.Announcer:Reset()
self.PlayNextArmed = false
return
end
if self.State == 1 and name == "R_ASNPMenu" and value then
self.State = 2
self.Selected = 0
-- self.Selected = 0
elseif self.State == 2 and value then
if name == "R_ASNPMenu" then
self.Selected = self.Selected + 1
if self.Selected > 2 then
self.State = 3
end
self.State = 3
end
if (name == "R_ASNPUp" or name == "R_ASNPDown") and self.Selected < 2 then
local sel = 1-self.Selected
local num = Format("%02d",self.RouteNumber)[self.Selected+1]
if name == "R_ASNPUp" then if num == "9" then self.RouteNumber = self.RouteNumber - 10^sel*9 else self.RouteNumber = self.RouteNumber + 10^sel end end
if name == "R_ASNPDown" then if num == "0" then self.RouteNumber = self.RouteNumber + 10^sel*9 else self.RouteNumber = self.RouteNumber - 10^sel end end
if (name == "R_ASNPUp" or name == "R_ASNPDown") then
local num = Format("%02d",self.RouteNumber)
if name == "R_ASNPUp" then self.RouteNumber = tonumber(self.RouteNumber)>=99 and 99 or self.RouteNumber+1 end
if name == "R_ASNPDown" then self.RouteNumber = tonumber(self.RouteNumber)<=0 and 0 or self.RouteNumber-1 end
end
if (name == "R_ASNPUp" or name == "R_ASNPDown") and self.Selected == 2 then self.Selected = 0 end
elseif self.State == 3 and value then
@@ -592,34 +579,19 @@ function TRAIN_SYSTEM:Trigger(name,value)
elseif self.State == 4 and value and not tbl[self.Line].Loop then --Не кольцевой
local stbl = Metrostroi.ASNPSetup[self.Train:GetNW2Int("Announcer",1)][self.Line]
if name == "R_ASNPDown" then
local found = false
for i=self.FirstStation+1,#stbl do
if stbl[i].arrlast then self.FirstStation = i;found=true;break end
end
if not found then
for i=1,#stbl do
if stbl[i].arrlast then self.FirstStation = i;break end
end
end
self.Station = math.min(#stbl,self.Station+1)
end
if name == "R_ASNPUp" then
local found = false
for i=self.FirstStation-1,1,-1 do
if stbl[i].arrlast then self.FirstStation = i;found=true;break end
end
if not found then
for i=#stbl,1,-1 do
if stbl[i].arrlast then self.FirstStation = i;break end
end
end
self.Station = math.max(1,self.Station-1)
end
if name == "R_ASNPMenu" then
self.State = 5
self.LastStation = 1
while stbl[self.LastStation] and not stbl[self.LastStation].arrlast or self.LastStation == self.FirstStation do
self.LastStation = self.LastStation - 1
if self.LastStation < 1 then self.LastStation = #stbl end
end
-- self.LastStation = 1
-- while stbl[self.LastStation] and not stbl[self.LastStation].arrlast or self.LastStation == self.Station do
-- self.LastStation = self.LastStation - 1
-- if self.LastStation < 1 then self.LastStation = #stbl end
-- end
self.FirstStation = self.Path and #stbl or 1
end
elseif self.State == 4 and value and tbl[self.Line].Loop then --Кольцевой
if name == "R_ASNPDown" or name == "R_ASNPUp" then
@@ -633,30 +605,18 @@ function TRAIN_SYSTEM:Trigger(name,value)
elseif self.State == 5 and value and not tbl[self.Line].Loop then --Не кольцевой
local stbl = Metrostroi.ASNPSetup[self.Train:GetNW2Int("Announcer",1)][self.Line]
if name == "R_ASNPDown" then
local found = false
for i=self.LastStation+1,#stbl do
if i ~= self.FirstStation and stbl[i].arrlast then self.LastStation = i;found=true;break end
end
if not found then
for i=1,#stbl do
if i ~= self.FirstStation and stbl[i].arrlast then self.LastStation = i;break end
end
for i=math.min(#stbl,self.LastStation+1),#stbl do
if i ~= self.Station and stbl[i].arrlast then self.LastStation = i;found=true;break end
end
end
if name == "R_ASNPUp" then
local found = false
for i=self.LastStation-1,1,-1 do
if i ~= self.FirstStation and stbl[i].arrlast then self.LastStation = i;found=true;break end
end
if not found then
for i=#stbl,1,-1 do
if i ~= self.FirstStation and stbl[i].arrlast then self.LastStation = i;break end
end
for i=math.max(1,self.LastStation-1),1,-1 do
if i ~= self.Station and stbl[i].arrlast then self.LastStation = i;found=true;break end
end
end
if name == "R_ASNPMenu" then
self.Path = self.FirstStation > self.LastStation
self.Station = self.FirstStation
self.Path = self.Station > self.LastStation
-- self.Station = self.FirstStation
if self.Path then
local first = self.LastStation
self.LastStation = self.FirstStation
@@ -697,20 +657,18 @@ function TRAIN_SYSTEM:Trigger(name,value)
self.Arrived = true
end
elseif self.State == 6 and value then
local stbl = Metrostroi.ASNPSetup[self.Train:GetNW2Int("Announcer",1)][self.Line]
if name == "R_ASNPDown" or name == "R_ASNPUp" then
self.State = 2
self.Selected = 0
self.Arrived = not self.Arrived
end
if name == "R_ASNPMenu" then
if self.FirstStation ~= 0 then
if self.LineOut>0 then self:AnnQueue{-2,"buzz_end","click2"} end
if self.Path then
self:AnnQueue{"click1","buzz_start","announcer_ready",stbl[self.LastStation].arrlast[3],stbl[self.FirstStation].arrlast[3],"buzz_end","click2"}
else
self:AnnQueue{"click1","buzz_start","announcer_ready",stbl[self.FirstStation].arrlast[3],stbl[self.LastStation].arrlast[3],"buzz_end","click2"}
end
end
-- if self.FirstStation ~= 0 then
-- if self.LineOut>0 then self:AnnQueue{-2,"buzz_end","click2"} end
-- if self.Path then
-- self:AnnQueue{"click1","buzz_start","announcer_ready",stbl[self.LastStation].arrlast[3],stbl[self.FirstStation].arrlast[3],"buzz_end","click2"}
-- else
-- self:AnnQueue{"click1","buzz_start","announcer_ready",stbl[self.FirstStation].arrlast[3],stbl[self.LastStation].arrlast[3],"buzz_end","click2"}
-- end
-- end
self.State = 7
self:UpdateBoards()
self:SyncASNP()
@@ -718,19 +676,23 @@ function TRAIN_SYSTEM:Trigger(name,value)
end
elseif self.State == 7 then
local stbl = Metrostroi.ASNPSetup[self.Train:GetNW2Int("Announcer",1)][self.Line]
if name == "R_ASNPMenu" and value then self.ReturnTimer = CurTime() end
if name == "R_ASNPMenu" and not value and self.ReturnTimer and self.ReturnTimer - CurTime() < 0.7 then
self.ReturnTimer = nil
-- if name == "R_ASNPMenu" and value then self.ReturnTimer = CurTime() end
-- if name == "R_ASNPMenu" and not value and self.ReturnTimer and self.ReturnTimer - CurTime() < 0.0 then
-- self.ReturnTimer = nil
-- end
if name == "R_ASNPMenu" and value then
self.State = 2
if self.LineOut>0 then self:AnnQueue{-2,"buzz_end","click2"} end
end
if name == "R_ASNPDown" and value then self:Next() end
if name == "R_ASNPUp" and value then self:Prev() end
if (name == "R_Program1" or name == "R_Program1H") and value then
-- if name == "R_ASNPDown" and value then self:Next() end
-- if name == "R_ASNPUp" and value then self:Prev() end
if (name == "R_Program1" or name == "R_Program1H") and value and (not self.Train.R_Radio or self.Train.R_Radio.Value>0) then
if self.LineOut>0 then self:AnnQueue{-2,"buzz_end","click2"} end
if self.Arrived and self.Station == (self.Path and self.FirstStation or self.LastStation) then
self:Zero()
end
self:Play(self.Arrived)
self:Next()
self.PlayNextArmed = true
end
end
end
@@ -762,7 +724,7 @@ function TRAIN_SYSTEM:Think()
self.ASNPTimer = CurTime()-math.Rand(-0.3,0.3)
end
if self.State == -1 and self.ASNPTimer and CurTime()-self.ASNPTimer > 1 then
self.State = Metrostroi.ASNPSetup and #Metrostroi.ASNPSetup > 0 and 1 or -2
self.State = Metrostroi.ASNPSetup and #Metrostroi.ASNPSetup > 0 and 7 or -2
end
if Power and self.State > -1 then
for k,v in pairs(self.TriggerNames) do
@@ -781,13 +743,22 @@ function TRAIN_SYSTEM:Think()
if self.PassSchemeWork then self:UpdateBoards() end
end
if self.ReturnTimer and CurTime()-self.ReturnTimer > 0.7 then
if self.State == 7 then
self.State = 6
if self.LineOut>0 then self:AnnQueue{-2,"buzz_end","click2"} end
end
self.ReturnTimer = nil
local LineOut = #Train.Announcer.Schedule>0 and 1 or 0
if self.PlayNextArmed and self.LineOut~=LineOut and self.LineOut==1 and LineOut==0 then
self:Next()
end
if self.TriggerButton and CurTime()>self.TriggerButtonTime+0.2 and Train[self.TriggerButton].Value>0 then
self:Trigger(self.TriggerButton,true)
end
-- if self.ReturnTimer and CurTime()-self.ReturnTimer > 0.7 then
-- if self.State == 7 then
-- self.State = 6
-- if self.LineOut>0 then self:AnnQueue{-2,"buzz_end","click2"} end
-- end
-- self.ReturnTimer = nil
-- end
Train:SetNW2Int("ASNP:State",self.State)
Train:SetNW2Int("ASNP:RouteNumber",self.RouteNumber)
@@ -799,7 +770,7 @@ function TRAIN_SYSTEM:Think()
Train:SetNW2Bool("ASNP:Station",self.Station)
Train:SetNW2Bool("ASNP:Arrived",self.Arrived)
self.LineOut = #Train.Announcer.Schedule>0 and 1 or 0
self.LineOut = LineOut
Train:SetNW2Bool("ASNP:Playing",self.LineOut>0)
if Train.VBD and self.State>0 then
Train:SetNW2Bool("ASNP:CanLocked",true)

View File

@@ -420,7 +420,7 @@ else
self.Error = CurTime()%0.5 > 0.25
elseif self.State == 2 then
if #self.Log > 100 then table.remove(self.Log,1) end
local Standby = CurTime()-self.StandbyTimer > 10
local Standby = CurTime()-self.StandbyTimer > 60
if self.State2 > 0 and Standby then self.State2 = 0 end
if self.ShowTimeTimer and self.ShowTimeTimer ~= true and CurTime()-self.ShowTimeTimer > 1.5 then
self.ShowTime = not self.ShowTime

View File

@@ -115,7 +115,7 @@ if CLIENT then
local Train = self.Train
local State = self.Train:GetNW2Int("IGLA:State",0)
if State > -2 then
surface.SetDrawColor(81,223,0,self.Warm and 100 or 255)
surface.SetDrawColor(140,190,0,self.Warm and 130 or 255)
surface.DrawRect(0,0,512,80)
self.Warm = true
else
@@ -136,8 +136,8 @@ if CLIENT then
end
if State2 == 0 then
--self:PrintText(0,"")
self:PrintText(0,Format("[%03d]",Train:GetNW2Int("IGLA:Messages")))
self:PrintText(7,"ПЦБК-"..Train:GetNW2Int("IGLA:Count",0))
self:PrintText(2,Format("[%03d]",Train:GetNW2Int("IGLA:Messages")))
self:PrintText(8,"ПЦБК-"..Train:GetNW2Int("IGLA:Count",0))
elseif State2 == 1 then
local w = Train:GetNW2Int("IGLA:WagNumber")
local m = Train:GetNW2String("IGLA:LogID")
@@ -246,7 +246,7 @@ else
function TRAIN_SYSTEM:Trigger(name,value)
if self.State == 2 then
if self.State2 == 0 then
if name == "IGLA2D" and value and #self.Log > 0 then
if name == "IGLA1" and value and #self.Log > 0 then
self.State2 = 1
self.StandbyTimer = CurTime()
self.Selected = #self.Log
@@ -256,9 +256,12 @@ else
self.StandbyTimer = CurTime()
self.Selected = #self.Messages
end
if name =="IGLA2" and value then
self.State = -2
end
elseif self.State2 == 1 then
self.StandbyTimer = CurTime()
if name == "IGLA2D" and value and self.Selected > 1 then
if name == "IGLA1" and value and self.Selected > 1 then
self.Selected = self.Selected - 1
end
if name == "IGLA2" and value then