Skip to content
Snippets Groups Projects
Commit ec5426c2 authored by Peter Nerlich's avatar Peter Nerlich
Browse files

add missing entries at Anmeldung, fix compile_fahrplan(), add experimental msg setting at platform

parent 5ecf1844
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@ S.lines = {
{name="Spawn",entry="west", platform="1", exit='south'},
{name="Freiluftkirche",entry="north", platform="2", exit='south'},
{name="Auditorium",entry="east", platform="1", exit='west'},
{name="Anmeldung",entry="south", platform="2", exit='north'},
}
},
......@@ -38,6 +39,7 @@ S.lines = {
stations= {
{name="Neuland HBF unten",entry="west", platform="U2", exit='south'},
{name="Auditorium",entry="south", platform="1", exit='west'},
{name="Anmeldung",entry="south", platform="2", exit='north'},
{name="Neuland HBF unten",entry="south", platform="U6", exit='west'},
},
turns = {'Neuland HBF unten'}
......@@ -70,7 +72,7 @@ S.lines = {
stations = {
{name = "Neuland HBF oben",entry="north", platform="1", exit="north"},
{name = "Schwimmbad",entry="west", platform="1", exit="east"},
{name = "Spawn",entry="west", platform="2", exit="shunt"},
{name = "Spawn",entry="west", platform="2", exit="shunt", msg_outside="NICHT EINSTEIGEN"},
{name = "Spawn",entry="shunt", platform="P2", exit="shunt"},
{name = "Spawn",entry="shunt", platform="1", exit="west"},
{name = "Schwimmbad",entry="east", platform="2", exit="west"},
......@@ -258,8 +260,8 @@ F._get_next_stops = function(station_index,line_data,turns)
return next_stops
end
-- for a station, find which platform a line stops at
F.platform_for_line = function(line, station, entry)
-- for a station, find matching info from S.lines
F.entry_match = function(line, station, entry)
if S.deactivated then
return
end
......@@ -267,7 +269,19 @@ F.platform_for_line = function(line, station, entry)
if S.lines_at_stations[station] == nil or S.lines_at_stations[station][line] == nil or S.lines_at_stations[station][line][entry] == nil then
return nil
end
return S.lines_at_stations[station][line][entry].platform
return F.util.clone(S.lines_at_stations[station][line][entry])
end
-- for a station, find which platform a line stops at
F.platform_for_line = function(line, station, entry)
if S.deactivated then
return
end
local info = F.entry_match(line, station, entry)
if info ~= nil then
return info.platform
end
end
-- broadcast table changes via interrupt_pos() and digiline
......@@ -353,7 +367,7 @@ F.enter_station = function(station, entry, line, announce_changes)
S.debug_data = {station = station,entry=entry}
end
local platform = F.platform_for_line(line, station, entry)
local info = F.entry_match(line, station, entry)
--print("[ATC enter_station("..F.util.pretty(station)..", "..F.util.pretty(entry)..", "..F.util.pretty(line)..", "..F.util.pretty(announce_changes)..")]")
......@@ -367,11 +381,15 @@ F.enter_station = function(station, entry, line, announce_changes)
if S.arrivals[station][atc_id] == nil then
S.arrivals[station][atc_id] = {}
end
S.arrivals[station][atc_id].line = line
S.arrivals[station][atc_id].status = "boarding"
S.arrivals[station][atc_id].platform = platform
local arrival = S.arrivals[station][atc_id]
arrival.line = line
arrival.status = "arriving"
if info ~= nil then
arrival.info = info
arrival.platform = info.platform
end
if S.lines_at_stations[station]~= nil and S.lines_at_stations[station][line] ~= nil and S.lines_at_stations[station][line][entry] ~= nil then
S.arrivals[station][atc_id].next_stops = S.lines_at_stations[station][line][entry].next_stops
arrival.next_stops = S.lines_at_stations[station][line][entry].next_stops
end
if announce_changes and platform ~= nil then
F.announce_table_changes(station, platform, line)
......@@ -443,9 +461,20 @@ F.enter_platform = function(station, platform, line, announce_changes)
if S.arrivals[station][atc_id] == nil then
S.arrivals[station][atc_id] = {}
end
S.arrivals[station][atc_id].line = line
S.arrivals[station][atc_id].status = "boarding"
S.arrivals[station][atc_id].platform = platform
local arrival = S.arrivals[station][atc_id]
arrival.line = line
arrival.status = "boarding"
arrival.platform = platform
if arrival.info then
if arrival.info.msg_outside then
arrival.info.reset_msg_outside = atc_get_text_outside()
atc_set_text_outside(arrival.info.msg_outside)
elseif arrival.info.msg_inside then
arrival.info.reset_msg_inside = atc_get_text_inside()
atc_set_text_inside(arrival.info.msg_inside)
end
end
if announce_changes then
F.announce_table_changes(station, platform, line)
......@@ -478,9 +507,18 @@ F.exit_platform = function(station, platform, line, announce_changes)
if S.arrivals[station][atc_id] == nil then
S.arrivals[station][atc_id] = {}
end
S.arrivals[station][atc_id].line = line
S.arrivals[station][atc_id].status = "departing"
S.arrivals[station][atc_id].platform = platform
local arrival = S.arrivals[station][atc_id]
arrival.line = line
arrival.status = "departing"
arrival.platform = platform
if arrival.info then
if arrival.info.reset_msg_outside then
atc_set_text_outside(arrival.info.reset_msg_outside)
elseif arrival.info.reset_msg_inside then
atc_set_text_inside(arrival.info.reset_msg_inside)
end
end
if announce_changes then
F.announce_table_changes(station, platform, line)
......@@ -622,11 +660,16 @@ F.compile_fahrplan = function(station,line_break,line_width)
local fahrplan_lines = {}
for line,line_data in pairs(S.lines_at_stations[station]) do
for entry,entry_data in pairs(line_data) do
local text_line = F.util.autopad({'Linie ' .. line ,' Gl. ' .. entry_data.platform},line_width,".")
local text_line = F.util.autopad({'Linie ' .. line .. ' ', ' Gl. ' .. entry_data.platform}, line_width, ".")
table.insert(fahrplan_lines,text_line)
text_line = ""
text_line = {}
for i,next_stop in ipairs(entry_data.next_stops) do
text_line = text_line .. next_stop .. ' '
table.insert(text_line, next_stop)
end
text_line = table.concat(text_line, ', ')
if #text_line < line_width then
text_line = text_line .. ' '
text_line = F.util.pad_right(text_line, line_width-#text_line, '.')
end
table.insert(fahrplan_lines, text_line)
end
......@@ -642,6 +685,20 @@ end
F.util = {}
F.util.clone = function(tbl, n)
local out = {}
local i,v = next(tbl, nil)
while i do
if type(v) == "table" then
out[i] = F.util.clone(v, (n or 0)+1)
else
out[i] = v
end
i,v = next(tbl, i)
end
return out
end
F.util.pretty = function(tbl, indent, lvl)
local s = ""
indent = indent or 2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment