summaryrefslogtreecommitdiff
path: root/subway/nodes/(10,0,-10).lua
blob: bc56a91a7f03e8539b434bdfd2c00ce16391fa71 (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
--  digiline_send("l14e", "SIS Variant 2 - v1.4 | No info avaliable")

local appr_time = 15
local dnnapprt=15
if not appr_tmr then appr_tmr = 0 end
local setint = false
if event.ext_int then
  if event.message == "dep1" then
    if n_appr then in_stn = n_appr + 0 end
    n_appr = 1
    n_wait = nil
    appr_tmr = appr_time
    setint=true
  elseif event.message == "dep4" then
    if n_appr then in_stn = n_appr + 0 end
    n_appr = 4
    n_wait = nil
    appr_tmr = appr_time
    setint=true
  elseif event.message == "arr1" then
    n_wait = 1
  elseif event.message == "arr4" then
    n_wait = 4
  elseif event.message == "arro" and not in_stn then
    in_stn = n_appr
    n_appr = nil
  elseif event.message == "depo" then
    in_stn = nil
  end
elseif event.int then
  appr_tmr = appr_tmr - 5
  setint=true
elseif event.punch then
  in_stn=nil
  n_appr=nil
  n_wait=nil
  digiline_send("l14e", "SIS Variant 2 - v1.4 | Please Wait")
end


-- calculate time for nwaiting train
if n_appr then
  nwt = math.max(appr_tmr, 0) + appr_time
elseif n_wait then
  nwt = math.max(appr_tmr, 0) + 10 + appr_time
end
--display
local seconds = "in "..appr_tmr.." s"
if appr_tmr <= 0 then
  seconds = "now"
end


local du_line, du_time, dd_line
if in_stn then
  du_line = in_stn
  du_time = "now"
  if n_appr then
    dd_line = n_appr
  else
    dd_line = n_wait
  end
elseif n_appr then
  du_line = n_appr
  du_time = seconds
  if n_wait then
    dd_line = n_wait
  end
elseif n_wait then
  du_line = n_wait
  du_time = "in 30 s"
end

local txt = {
  [1] = "Windy Mtns.",
  [4] = "Schwarzs...",
}
local line1, line2, line3 = "", "", ""
if du_line then
  line1 = "Line "..du_line
  line2 = txt[du_line]
  line3 = du_time
end
local line4 = ""
if dd_line and nwt then
  line4 = "Line "..(dd_line).." - "..nwt.."s"
end
digiline_send("l14e", line1.." | "..line2.." | "..line3.." | ----------- | "..line4)

digiline_send("l14eint", "in_st:"..(in_stn or "-").." "..appr_tmr.."s".." | n_appr: "..(n_appr or "-").." | n_wait: "..(n_wait or "-").. " | "..event.type.." | "..(event.message or "-"))

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