fix: correctly assign State.upcomingTrains before display link fallback
This commit is contained in:
@@ -2103,7 +2103,7 @@ function Display.render()
|
|||||||
|
|
||||||
-- Upcoming Trains
|
-- Upcoming Trains
|
||||||
if State.upcomingTrains and #State.upcomingTrains > 0 then
|
if State.upcomingTrains and #State.upcomingTrains > 0 then
|
||||||
local startY = State.currentTrain and 11 or 7
|
local startY = State.currentTrain and 10 or 7
|
||||||
mon.setCursorPos(1, startY)
|
mon.setCursorPos(1, startY)
|
||||||
mon.setTextColor(COLORS.DEBUG)
|
mon.setTextColor(COLORS.DEBUG)
|
||||||
mon.write("UPCOMING TRAINS:")
|
mon.write("UPCOMING TRAINS:")
|
||||||
@@ -2327,8 +2327,11 @@ function Main.loop()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Fallback to Display Link text parsing if Block Reader is not available
|
-- Update Upcoming Trains globally for the monitor
|
||||||
elseif Peripherals.createTarget then
|
State.upcomingTrains = newUpcoming
|
||||||
|
|
||||||
|
-- Try CC:C Bridge Display Link (Legacy Text Parsing) if Block Reader is not available
|
||||||
|
if not Peripherals.blockReader and Peripherals.createTarget then
|
||||||
local lines = Peripherals.createTarget.dump()
|
local lines = Peripherals.createTarget.dump()
|
||||||
|
|
||||||
for k, v in pairs(State.announcedApproaching) do
|
for k, v in pairs(State.announcedApproaching) do
|
||||||
@@ -2409,7 +2412,6 @@ function Main.loop()
|
|||||||
|
|
||||||
if not Peripherals.station then
|
if not Peripherals.station then
|
||||||
State.currentTrain = nil
|
State.currentTrain = nil
|
||||||
State.upcomingTrains = newUpcoming
|
|
||||||
Display.render()
|
Display.render()
|
||||||
Display.renderTerminal()
|
Display.renderTerminal()
|
||||||
os.sleep(0.5)
|
os.sleep(0.5)
|
||||||
@@ -2472,7 +2474,6 @@ function Main.loop()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
State.upcomingTrains = newUpcoming
|
|
||||||
Display.render()
|
Display.render()
|
||||||
Display.renderTerminal()
|
Display.renderTerminal()
|
||||||
os.sleep(0.5)
|
os.sleep(0.5)
|
||||||
|
|||||||
Reference in New Issue
Block a user