summaryrefslogtreecommitdiff
path: root/subway/nodes/(-14,3,4).lua
blob: 825989c265914e91333a851e40692f392bd3b80b (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--  digiline_send("l14w", "SIS Variant 2 - v1.4 | No info avaliable")


local appr_time = {[1]=15, [4]=15}
if not appr_tmr then appr_tmr = 0 end
local setint = false
if event.ext_int then
  if event.message == "dep4" then
     next_appr = 4
     appr_tmr = appr_time[4]
     nwaiting = nnwaiting
     nnwaiting = nil
     setint=true
  elseif event.message == "dep1" then
     next_appr = 1
     appr_tmr = appr_time[1]
     nwaiting = nnwaiting
     nnwaiting = nil
     setint=true
  elseif event.message == "arr1" then
    if nwaiting then nnwaiting = 1 else nwaiting = 1 end
  elseif event.message == "arr4" then
    if nwaiting then nnwaiting = 4 else nwaiting = 4 end
  elseif event.message == "depo" then
    next_appr = nil
  end
elseif event.int then
  appr_tmr = appr_tmr - 5
  setint=true
else
  next_appr = nil
  nwaiting = nil
  nnwaiting = nil
  digiline_send("l14w", "SIS Variant 2 - v1.4 | Please Wait")
  return
end

-- calculate time for nwaiting train
local nwt = 0
if nwaiting then
  nwt = appr_tmr + 10 + appr_time[nwaiting]
end
--display
local seconds = appr_tmr
if appr_tmr <= 0 then
  seconds = ""
end
local txt = {
  [1] = "Palm Bay",
  [4] = "Apple Grove",
}
local line1, line2, line3 = "", "", ""
if next_appr then
  line1 = "Line "..next_appr
  line2 = txt[next_appr]
  line3 = "in " .. seconds.."s"
  if seconds == "" then
    line3 = "now"
  end
end
local line4 = ""
if nwt>0 then
  line4 = "Line "..nwaiting.." - "..nwt.."s"
end
digiline_send("l14w", line1.." | "..line2.." | "..line3.." | ----------- | "..line4)

digiline_send("l14wint", "Appr: "..(next_appr or "-").." "..appr_tmr.."s".." | nwaiting: "..(nwaiting or "-").." | nnwaiting: "..(nnwaiting or "-").. " | "..event.type.." | "..(event.message or "-"))

if appr_tmr > 0 and setint then
  interrupt(5, "appr")
end