summaryrefslogtreecommitdiff
path: root/Crossroads/nodes/(1780,27,929).lua
blob: 98c6d83d5b669d867ef5a871697f95d61260df80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
if event.type ~= "punch" then
  return
end

local st = {}
local function println(str)
  table.insert(st, str)
end
local function printf(fmt, ...)
  return println(string.format(fmt, ...))
end

local lines = F.lines
local linenames = {}

for k in pairs(lines) do
  table.insert(linenames, k)
end
table.sort(linenames)

for _, linename in ipairs(linenames) do
  local line = lines[linename]
  printf("Line: %s", linename)
  printf("Ring: %s", line.ring)
  printf("Interval: %s", line.interval or "?")
  printf("Trip length: %s", line.rtt or "?")
  for tripnum, trip in ipairs(line) do
    printf("Trip #%d", tripnum)
    for _, stn in ipairs(trip) do
      local stnline = ("%-27s %-3s"):format(F.stnlist[stn[1]] or stn[1], stn[2])
      if stn[3] then
        stnline = stnline .. (" %02d:%02d"):format(math.floor(stn[3]/60), stn[3]%60)
      end
      println(stnline)
    end
  end
  println("")
end

local text = table.concat(st, "\n")
digiline_send("mfu", {
  command = "PRINT",
  copies = 1,
  author = "Station Control Center",
  title = "Timetable",
  text = text,
  watermark = "CRT_" .. os.time(),
})