diff options
Diffstat (limited to 'Crossroads')
30 files changed, 135 insertions, 36 deletions
diff --git a/Crossroads/init_code.lua b/Crossroads/init_code.lua index 62840ef..d6fb5f4 100644 --- a/Crossroads/init_code.lua +++ b/Crossroads/init_code.lua @@ -7,6 +7,11 @@ function F.dst() if os.date().isdst then return "CEST" else return "CET" end end +function F.pccheck(pos, state) + if is_passive(pos) then return true end + return (getstate(pos) == state) +end + -- F.error - Send error with error code function F.error(errorcode) error(F.errlist[errorcode]) @@ -114,7 +119,6 @@ function F.stn2gen(stn, trk, door, ret, chout) if not trk then return end if not door then return end if door~="L" and door~="R" and door~="C" then return end - if event.type~="train" then return end if not atc_arrow then return end if not F.stndet[stn] then return end if not F.stndet[stn][trk] then return end @@ -123,30 +127,46 @@ function F.stn2gen(stn, trk, door, ret, chout) if #t==0 then return end local l = get_line() if (not l) or l==" " then return end - if (get_rc() or ""):match("FREIGHT") then + local rc = get_rc() or "" + if rc:match("FREIGHT") then atc_send (ret and "BBWRSM" or "SM") return end - for i = 1, #t, 1 do - if t[i][1]==l then - stop = true - atc_send("BBWO"..door.."D15OCD1"..(ret and "R" or "").."SM") - local intext = (F.stnlist[stn] or stn).."\n"..(F.stnlist[t[i][2]] and "Next station: "..F.stnlist[t[i][2]]..(t[i][3] and " (track "..t[i][3]..")" or "") or "End of Line") - local outtext = string.format("%s (%06d)",F.lines[l].name or l, atc_id) - if t[i][4] then outtext = outtext.." - "..(F.stnlist[t[i][4]] or t[i][4]) end - atc_set_text_inside(intext) - if chout then atc_set_text_outside(outtext) end - S.trains[atc_id] = { - v = 2, - l = (get_line() or ""), - s = stn, - t = (trk or "N/A"), - } - break + if event.type == "train" then + for i = 1, #t, 1 do + if t[i][1]==l then + stop = true + atc_send(string.format("BBWO%sD15OCD1%sSM", door, (ret and "R" or ""))) + local intext_nxt = F.stnlist[t[i][2]] and ("Next station:\n%s\n(Track: %s)"):format(F.stnlist[t[i][2]], t[i][3] or "?") or "" + local intext = ("%s\n%s"):format(F.stnlist[stn] or stn, intext_nxt) + local outtext = string.format("%s (%06d)",F.lines[l].name or l, atc_id) + if t[i][4] then outtext = outtext.." - "..(F.stnlist[t[i][4]] or t[i][4]) end + local timenow = os.time() + 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]) + t[i][5] = timenow + atc_set_text_inside(intext) + if chout then atc_set_text_outside(outtext) end + S.trains[atc_id] = { + v = 2, + l = (get_line() or ""), + s = stn, + t = (trk or "N/A"), + } + schedule_in(15, intext_nxt) + break + end + end + if (not stop) then + atc_send(ret and "BBWRSM" or "SM") end end - if (not stop) then - atc_send(ret and "BBWRSM" or "SM") + if event.type == "schedule" then + if type(event.msg) == "string" then + atc_set_text_inside(event.msg) + atc_send(ret and "OCD1RSM" or "OCD1SM") + end end end @@ -154,7 +174,8 @@ function F.disp2gen(stn) if not stn then return end if not F.stndet[stn] then return end local s = F.stndet[stn] - local d={{(F.stnlist[stn] or stn).."\nTrack Line\n", os.date("%Y-%m-%d %H:%M %z", os.time()).."\nDestination\n"}} + local sn = F.stnlist[stn] or stn + local d={{sn.."\nTrack Line\n", (string.sub(sn, 28, 54) or "").." \nDestination\n", " \nEstimated Arrival\n"}} local c=2 local t={} for i,_ in pairs(s) do t[#t+1]=i end @@ -169,6 +190,8 @@ function F.disp2gen(stn) d[r][1] = d[r][1] .. string.format("%-8s %s\n", tostring(trkname), F.lines[det[1]].name) d[r][2] = d[r][2] .. (F.lines[det[1]].ring and "Ring Line" or (F.stnlist[det[4]] or det[4] or "")).."\n" 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] .. os.date("%Y-%m-%d %H:%M %Z", earr) .. "\n" end end for i = 1, #d, 1 do @@ -231,6 +254,7 @@ F.stnlist = { elgp = "Erstaziland-Greener Pastures", elsf = "Erstaziland-Salt Factory", evo = "EVO", + grsc = "Grassy Scarp", mushroom = "Mushroom Land", neverbuild = "Neverbuild", nvbcentral = "Neverbuild Central", @@ -253,14 +277,14 @@ F.lines = { ["AB"] = { name = "ATL Bronze Line", ring = false, - [1] = { {"crch","A1"}, --[[ {"crwm","3"}, ]] {"scs","N"}, {"scc","N"}, {"scn","N"}, {"cg","1"}, {"thecube","4"}, {"phsc","N"}, {"phwest","7"} }, - [2] = { {"phwest","7"}, {"phsc","S"}, {"thecube","1"}, {"cg","2"}, {"scn","S"}, {"scc","S"}, {"scs","S"}, --[[ {"crwm","4"}, ]] {"crch","A1"} }, + [1] = { {"crch","A1"}, --[[ {"crwm","3"}, ]] {"scs","N2"}, {"scc","N2"}, {"scn","N2"}, {"cg","1"}, {"thecube","4"}, {"phsc","N"}, {"grsc", "4"}, {"phwest","1"} }, + [2] = { {"phwest","1"}, {"grsc", "3"}, {"phsc","S"}, {"thecube","1"}, {"cg","2"}, {"scn","S2"}, {"scc","S2"}, {"scs","S2"}, --[[ {"crwm","4"}, ]] {"crch","A1"} }, }, ["AZ"] = { name = "ATL Zinc Line", ring = false, - [1] = { {"evo","N/A"}, {"scs","N"}, {"scc","N"}, {"scn","N"}, {"oc","N"}, {"elgp","N"}, {"elsf","E"}, {"elchateau","S"} }, - [2] = { {"elchateau","S"}, {"elsf","W"}, {"elgp","S"}, {"oc","S"}, {"scn","S"}, {"scc","S"}, {"scs","S"}, {"evo","N/A"} }, + [1] = { {"evo","N/A"}, {"scs","N1"}, {"scc","N1"}, {"scn","N1"}, {"oc","N"}, {"elgp","N"}, {"elsf","E"}, {"elchateau","S"} }, + [2] = { {"elchateau","S"}, {"elsf","W"}, {"elgp","S"}, {"oc","S"}, {"scn","S1"}, {"scc", "S1"}, {"scs","S1"}, {"evo","N/A"} }, }, ["CRT1"] = { name = "CRT 1", @@ -306,7 +330,7 @@ F.errlist = { } F.depint = { - ["AB"] = 60, + ["AB"] = 90, ["AG"] = 120, ["CRT1"] = 30, } diff --git a/Crossroads/nodes/(-1904,2,706).lua b/Crossroads/nodes/(-1904,2,706).lua new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Crossroads/nodes/(-1904,2,706).lua diff --git a/Crossroads/nodes/(-1906,2,698).lua b/Crossroads/nodes/(-1906,2,698).lua new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Crossroads/nodes/(-1906,2,698).lua diff --git a/Crossroads/nodes/(1114,18,2767).lua b/Crossroads/nodes/(1114,18,2767).lua new file mode 100644 index 0000000..1d543d8 --- /dev/null +++ b/Crossroads/nodes/(1114,18,2767).lua @@ -0,0 +1,5 @@ +if event.type == "punch" then + digiline_send("s", "<- Track 2 | Track 3 ->") +elseif event.type == "digiline" and event.channel == "pis" then + F.disp2gen("grsc") +end
\ No newline at end of file diff --git a/Crossroads/nodes/(1116,12,2621).lua b/Crossroads/nodes/(1116,12,2621).lua new file mode 100644 index 0000000..3b6577d --- /dev/null +++ b/Crossroads/nodes/(1116,12,2621).lua @@ -0,0 +1 @@ +F.disp2gen("phsc")
\ No newline at end of file diff --git a/Crossroads/nodes/(1116,12,2653).lua b/Crossroads/nodes/(1116,12,2653).lua new file mode 100644 index 0000000..3b6577d --- /dev/null +++ b/Crossroads/nodes/(1116,12,2653).lua @@ -0,0 +1 @@ +F.disp2gen("phsc")
\ No newline at end of file diff --git a/Crossroads/nodes/(1119,16,2760).lua b/Crossroads/nodes/(1119,16,2760).lua new file mode 100644 index 0000000..dde01ed --- /dev/null +++ b/Crossroads/nodes/(1119,16,2760).lua @@ -0,0 +1 @@ +F.stn2gen("grsc", "3", "R")
\ No newline at end of file diff --git a/Crossroads/nodes/(1122,10,2639).lua b/Crossroads/nodes/(1122,10,2639).lua new file mode 100644 index 0000000..5d35b02 --- /dev/null +++ b/Crossroads/nodes/(1122,10,2639).lua @@ -0,0 +1 @@ +F.stn2gen("phsc", "N", "L")
\ No newline at end of file diff --git a/Crossroads/nodes/(1122,16,2768).lua b/Crossroads/nodes/(1122,16,2768).lua new file mode 100644 index 0000000..27a6f78 --- /dev/null +++ b/Crossroads/nodes/(1122,16,2768).lua @@ -0,0 +1 @@ +F.stn2gen("grsc", "4", "R")
\ No newline at end of file diff --git a/Crossroads/nodes/(1122,19,3014).lua b/Crossroads/nodes/(1122,19,3014).lua new file mode 100644 index 0000000..da8687d --- /dev/null +++ b/Crossroads/nodes/(1122,19,3014).lua @@ -0,0 +1 @@ +F.stn2gen("phwest", "1", "R", true, true)
\ No newline at end of file diff --git a/Crossroads/nodes/(1171,0,852).lua b/Crossroads/nodes/(1171,0,852).lua new file mode 100644 index 0000000..a49b39e --- /dev/null +++ b/Crossroads/nodes/(1171,0,852).lua @@ -0,0 +1 @@ +F.stn2gen("scs", "S2", "R")
\ No newline at end of file diff --git a/Crossroads/nodes/(1185,5,857).lua b/Crossroads/nodes/(1185,5,857).lua new file mode 100644 index 0000000..7e492db --- /dev/null +++ b/Crossroads/nodes/(1185,5,857).lua @@ -0,0 +1 @@ +F.stn2gen("scs","N2","L")
\ No newline at end of file diff --git a/Crossroads/nodes/(1187,-6,1084).lua b/Crossroads/nodes/(1187,-6,1084).lua new file mode 100644 index 0000000..50b540e --- /dev/null +++ b/Crossroads/nodes/(1187,-6,1084).lua @@ -0,0 +1 @@ +F.stn2gen("scn", "S2", "R")
\ No newline at end of file diff --git a/Crossroads/nodes/(1187,-6,996).lua b/Crossroads/nodes/(1187,-6,996).lua new file mode 100644 index 0000000..5c86126 --- /dev/null +++ b/Crossroads/nodes/(1187,-6,996).lua @@ -0,0 +1 @@ +F.stn2gen("scc", "S2", "R")
\ No newline at end of file diff --git a/Crossroads/nodes/(1190,-6,1081).lua b/Crossroads/nodes/(1190,-6,1081).lua index 7a13d35..2779b52 100644 --- a/Crossroads/nodes/(1190,-6,1081).lua +++ b/Crossroads/nodes/(1190,-6,1081).lua @@ -1 +1,2 @@ -F.stn2gen("scn","S","R")
\ No newline at end of file +if atc_id and get_line() == "AZ" then atc_set_text_outside("ATL Zinc Line") end +F.stn2gen("scn","S1","L")
\ No newline at end of file diff --git a/Crossroads/nodes/(1198,-6,1092).lua b/Crossroads/nodes/(1198,-6,1092).lua index 345042a..9023aa8 100644 --- a/Crossroads/nodes/(1198,-6,1092).lua +++ b/Crossroads/nodes/(1198,-6,1092).lua @@ -1 +1 @@ -F.stn2gen("scn","N","R")
\ No newline at end of file +F.stn2gen("scn","N1","L")
\ No newline at end of file diff --git a/Crossroads/nodes/(1201,-6,1087).lua b/Crossroads/nodes/(1201,-6,1087).lua new file mode 100644 index 0000000..e0c8632 --- /dev/null +++ b/Crossroads/nodes/(1201,-6,1087).lua @@ -0,0 +1 @@ +F.stn2gen("scn","N2","R")
\ No newline at end of file diff --git a/Crossroads/nodes/(1201,-6,999).lua b/Crossroads/nodes/(1201,-6,999).lua new file mode 100644 index 0000000..855f755 --- /dev/null +++ b/Crossroads/nodes/(1201,-6,999).lua @@ -0,0 +1 @@ +F.stn2gen("scc", "N2", "R")
\ No newline at end of file diff --git a/Crossroads/nodes/(1400,21,819).lua b/Crossroads/nodes/(1400,21,819).lua index 5fbaddf..97c3d17 100644 --- a/Crossroads/nodes/(1400,21,819).lua +++ b/Crossroads/nodes/(1400,21,819).lua @@ -1,4 +1 @@ --- F.bhf("crwm","scs","L","M",nil,"FW") -if event.type == 'train' then -atc_set_text_inside('This train does not stop at Crossroads West Mountains due to the state of emergency in Crossroads.\nNext stop: Silver Coast South') -end
\ No newline at end of file +-- F.bhf("crwm","scs","L","M",nil,"FW")
\ No newline at end of file diff --git a/Crossroads/nodes/(1755,27,942).lua b/Crossroads/nodes/(1755,27,942).lua index f208c95..f8ddd3f 100644 --- a/Crossroads/nodes/(1755,27,942).lua +++ b/Crossroads/nodes/(1755,27,942).lua @@ -1,5 +1,3 @@ -if event.type == "digiline" then - if event.channel == "upd_wrapper" then - digiline_send("upd_main","") - end +if event.type == "digiline" and event.channel == "upd" then + digiline_send("upd_main","") end
\ No newline at end of file diff --git a/Crossroads/nodes/(1756,4,1010).lua b/Crossroads/nodes/(1756,4,1010).lua new file mode 100644 index 0000000..b5d5a9d --- /dev/null +++ b/Crossroads/nodes/(1756,4,1010).lua @@ -0,0 +1 @@ +-- test
\ No newline at end of file diff --git a/Crossroads/nodes/(2006,3,5953).lua b/Crossroads/nodes/(2006,3,5953).lua new file mode 100644 index 0000000..cd35a9e --- /dev/null +++ b/Crossroads/nodes/(2006,3,5953).lua @@ -0,0 +1,6 @@ +if event.type == "train" and atc_arrow then + if getstate("mary4-testturnout-2") ~= "cr" then + atc_send("BB") + error("Incorrect turnout position - correct route and test again") + end +end
\ No newline at end of file diff --git a/Crossroads/nodes/(2010,3,5938).lua b/Crossroads/nodes/(2010,3,5938).lua new file mode 100644 index 0000000..99bcc37 --- /dev/null +++ b/Crossroads/nodes/(2010,3,5938).lua @@ -0,0 +1,6 @@ +if event.type == "punch" then + for i = 1, 4, 1 do + cancel_route("mary4-testsignal-"..tostring(i)) + end + digiline_send("lcd", tostring(os.time()).."\nRoutes canceled") +end
\ No newline at end of file diff --git a/Crossroads/nodes/(2013,3,5923).lua b/Crossroads/nodes/(2013,3,5923).lua new file mode 100644 index 0000000..373dd5a --- /dev/null +++ b/Crossroads/nodes/(2013,3,5923).lua @@ -0,0 +1,6 @@ +if event.type == "train" and atc_arrow then + if getstate("mary4-testturnout-1") ~= "cr" then + atc_send("BB") + error("Incorrect turnout position - correct route and test again") + end +end
\ No newline at end of file diff --git a/Crossroads/nodes/(2013,3,5931).lua b/Crossroads/nodes/(2013,3,5931).lua new file mode 100644 index 0000000..9674660 --- /dev/null +++ b/Crossroads/nodes/(2013,3,5931).lua @@ -0,0 +1,6 @@ +if event.type == "train" and atc_arrow then + if getstate("mary4-testturnout-1") ~= "st" then + atc_send("BB") + error("Incorrect turnout position - correct route and test again") + end +end
\ No newline at end of file diff --git a/Crossroads/nodes/(2013,3,5961).lua b/Crossroads/nodes/(2013,3,5961).lua new file mode 100644 index 0000000..45e3f0a --- /dev/null +++ b/Crossroads/nodes/(2013,3,5961).lua @@ -0,0 +1,6 @@ +if event.type == "train" and atc_arrow then + if getstate("mary4-testturnout-2") ~= "st" then + atc_send("BB") + error("Incorrect turnout position - correct route and test again") + end +end
\ No newline at end of file diff --git a/Crossroads/nodes/(2065,5,978).lua b/Crossroads/nodes/(2065,5,978).lua index 29f42b5..e4c501a 100644 --- a/Crossroads/nodes/(2065,5,978).lua +++ b/Crossroads/nodes/(2065,5,978).lua @@ -1,9 +1,15 @@ +local outline = "AB" +local outrc = "" if event.type=="train" then if atc_arrow then atc_send("OC") atc_set_text_outside("") atc_set_text_inside("") set_rc("") + else + if outline then set_line(outline) end + if outrc then set_rc(outrc) end + atc_set_text_outside("Not in service") end --unset_shunt() end
\ No newline at end of file diff --git a/Crossroads/nodes/(2260,5,837).lua b/Crossroads/nodes/(2260,5,837).lua new file mode 100644 index 0000000..e1cd252 --- /dev/null +++ b/Crossroads/nodes/(2260,5,837).lua @@ -0,0 +1,10 @@ +if event.type == "train" then + atc_send("OCBBWI+R;") +end +if event.type == "ext_int" then + if atc_id then + set_line("2") + atc_set_text_outside("LINE 2") + atc_send("S4") + end +end
\ No newline at end of file diff --git a/Crossroads/nodes/(2260,5,893).lua b/Crossroads/nodes/(2260,5,893).lua new file mode 100644 index 0000000..2149070 --- /dev/null +++ b/Crossroads/nodes/(2260,5,893).lua @@ -0,0 +1,10 @@ +if event.type == "train" then + atc_send("OCBBWI+R;") +end +if event.type == "ext_int" then + if atc_id then + set_line("1") + atc_set_text_outside("LINE 1") + atc_send("S4") + end +end
\ No newline at end of file diff --git a/Crossroads/nodes/(2263,5,897).lua b/Crossroads/nodes/(2263,5,897).lua new file mode 100644 index 0000000..6656f49 --- /dev/null +++ b/Crossroads/nodes/(2263,5,897).lua @@ -0,0 +1,5 @@ +local status = false +if event.type == "punch" and status then + interrupt_pos(POS(2260,5,893), "") + interrupt_pos(POS(2260,5,837), "") +end
\ No newline at end of file |