summaryrefslogtreecommitdiff
path: root/Crossroads/init_code.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Crossroads/init_code.lua')
-rw-r--r--Crossroads/init_code.lua57
1 files changed, 43 insertions, 14 deletions
diff --git a/Crossroads/init_code.lua b/Crossroads/init_code.lua
index 645b0cb..7d1b5ac 100644
--- a/Crossroads/init_code.lua
+++ b/Crossroads/init_code.lua
@@ -191,7 +191,7 @@ function F.stn2gen(stn, trk, door, ret, chout, depspeed)
__approach_callback_mode = 1
if not stn then return end
if not trk then return end
- if not door then return end
+ if not door then door = "R" end
if door~="L" and door~="R" and door~="C" then return end
if not atc_arrow then return end
if not F.stndet[stn] then return end
@@ -229,16 +229,20 @@ function F.stn2gen(stn, trk, door, ret, chout, depspeed)
for i = 1, #t, 1 do
if t[i][1]==l then
stop = true
- local timenow = os.time()
+ local timenow = rwt.to_secs(rwt.now())
local interval = F.lines[l].interval
local offset = t[i][7]
- local arroff
+ local arroff, arrts, depts
if interval and offset then
arroff = timenow%(F.lines[l].rtt or interval)
interval = (offset-timenow)%interval
interval = math.max(5, math.min(45, interval))
+ arrts = ("%s (%s)"):format(rwt.to_string(timenow), rwt.to_string(arroff, true))
+ depts = ("%s (%s)"):format(rwt.to_string(timenow+interval), rwt.to_string(arroff+interval, true))
else
interval = 15
+ arrts = rwt.to_string(timenow)
+ depts = rwt.to_string(timenow+interval)
end
--atc_send(string.format("A0B0WO%sD%dOCD1%sA1S%s", door, interval, (ret and "R" or ""), tostring(depspeed or "M")))
atc_send(("B0WO%s"):format(door))
@@ -249,9 +253,14 @@ function F.stn2gen(stn, trk, door, ret, chout, depspeed)
intext_nxt = F.stnlist[nxt] and ("Next station: %s (Track: %s)"):format(F.stnlist[nxt], t[i][3] or "?") or ""
nxtdisp = intext_nxt
end
- local intext = ("%s\n%s\nDebug: %d %d"):format(F.stnlist[stn] or stn, intext_nxt, arroff or timenow, interval)
+ local intext = ("%s\n%s\nArrival: %s\nDeparture: %s"):format(F.stnlist[stn] or stn, intext_nxt, arrts, depts)
local outtext = F.lines[l].name or l
- if t[i][4] then outtext = outtext..": "..(F.stnlist[t[i][4]] or t[i][4]) end
+ if t[i].dest then
+ chout = true
+ outtext = outtext..": "..t[i].dest
+ elseif t[i][4] then
+ outtext = outtext..": "..(F.stnlist[t[i][4]] or t[i][4])
+ end
t[i][5] = t[i][5] or (timenow-(F.depint[l] or 300))
-- note that the "average" time is weighted
t[i][6] = t[i][6] and (t[i][6]+timenow-t[i][5]+30)/2 or (timenow-t[i][5])
@@ -326,8 +335,8 @@ function F.disp2gen(stn)
d[r][1][#d[r][1]+1] = string.format("%-8s %s", tostring(trkname), F.lines[det[1]].name)
d[r][2][#d[r][2]+1] = (F.lines[det[1]].ring and "Ring Line" or (F.stnlist[det[4]] or det[4] or ""))
c=c+1
- local earr = (det[5] or os.time())+(det[6] or F.depint[det[1]] or 600)
- d[r][3][#d[r][3]+1] = os.date("%Y-%m-%d %H:%M %Z", earr)
+ local earr = (det[5] or rwt.to_secs(rwt.now()))+(det[6] or F.depint[det[1]] or 600)
+ d[r][3][#d[r][3]+1] = rwt.to_string(earr)
end
end
for i = 1, #d, 1 do
@@ -459,10 +468,15 @@ F.stnlist = {
scc = "Silver Coast Central",
scn = "Silver Coast North",
scs = "Silver Coast South",
+ ["SWALD-harbor"] = "Sakurawäldle Hafen",
["SWALD-south"] = "Sakurawäldle Süd",
["SWALD-stn"] = "Sakurawäldle",
["SWALD-west"] = "Sakurawäldle West",
thecube = "The Cube",
+ ["TSV-island"] = "Tung Sha Tsuen Island",
+ ["TSV-mountain"] = "Tung Sha Tsuen Mountain Cabin",
+ ["TSV-pond"] = "Tung Sha Tsuen Pond",
+ ["TSV-sharbor"] = "South Harbor",
}
for k, v in pairs{[1] = "Station",} do
@@ -545,10 +559,20 @@ F.lines = {
["NRG3"] = {
name = "3",
ring = false,
- rtt = 600,
+ rtt = 1200,
interval = 300,
- [1] = { {"SWALD-south", "2b", 45}, {"SWALD-stn", "N", 85}, {"SWALD-west", "W", 115}, {"krasnograd", "2", 195}, {"NRG-pek", "2", 235}, {"NRG-CW", "S", 280}, {"NRG-krstr", "S", 310}, {"NRG-yard", "W", 340}, },
- [2] = { {"NRG-yard", "W", 340}, {"NRG-krstr", "N", 370}, {"NRG-CW", "N", 400}, {"NRG-pek", "1", 440}, {"krasnograd", "1", 495}, {"SWALD-west", "E", 575}, {"SWALD-stn", "S", 605}, {"SWALD-south", "2b", 645}, },
+ [1] = {
+ {"TSV-pond", "T", 40, dest = "New Roses Gardens\nvia Sakurawäldle, Krasnograd"}, {"TSV-sharbor", "S", 95}, {"TSV-island", "W", 145}, {"TSV-mountain", "W", 200},
+ {"SWALD-harbor", "W", 305, dest = "New Roses Gardens\nvia Krasnograd"}, {"SWALD-south", "W", 345}, {"SWALD-stn", "N", 385}, {"SWALD-west", "W", 415},
+ {"krasnograd", "2", 495, dest = "Betriebshof"},
+ {"NRG-pek", "2", 535}, {"NRG-CW", "S", 580}, {"NRG-krstr", "S", 610}, {"NRG-yard", "W", 640},
+ },
+ [2] = {
+ {"NRG-yard", "W", 640, dest = "Tung Sha Tsuen\nvia Krasnograd, Sakurawäldle"}, {"NRG-krstr", "N", 670}, {"NRG-CW", "N", 700}, {"NRG-pek", "1", 740},
+ {"krasnograd", "1", 795, dest = "Tung Sha Tsuen\nvia Sakurawäldle"},
+ {"SWALD-west", "E", 875, dest = "Tung Sha Tsuen Pond"}, {"SWALD-stn", "S", 905}, {"SWALD-south", "E", 945}, {"SWALD-harbor", "E", 985},
+ {"TSV-mountain", "E", 1090}, {"TSV-island", "E", 1145}, {"TSV-sharbor", "N", 1195}, {"TSV-pond", "T", 1240},
+ },
},
}
@@ -595,16 +619,21 @@ for i, l in pairs(F.lines) do
local s = dir[k][1]
local t = dir[k][2]
local o = dir[k][3]
+ local dest = dir[k].dest
if not F.stndet[s] then F.stndet[s] = {} end
if not F.stndet[s][t] then F.stndet[s][t] = {} end
local det = F.stndet[s][t]
if k~=#dir or l.ring then
local nxt = dir[k==#dir and 1 or k+1]
- det[#det+1] = {i, nxt[1], nxt[2], l.ring or dir[#dir][1], nil, nil, o}
+ det[#det+1] = {i, nxt[1], nxt[2], l.ring or dir[#dir][1], nil, nil, o, dest = dest}
else
local addent = true
- for m = 1, #l, 1 do addent = addent and (l[m][1]==dir[k]) end
- if addent then det[#det+1] = {i, nil, nil, s, nil, nil, o} end
+ for m = 1, #l, 1 do
+ addent = addent and (l[m][1]==dir[k])
+ end
+ if addent then
+ det[#det+1] = {i, nil, nil, s, nil, nil, o, dest = dest}
+ end
end
end
end
@@ -694,4 +723,4 @@ function F.cpoint(name, int)
S.cpoints[name] = now
atc_send("A1SM")
end
-end \ No newline at end of file
+end