From cfa65d94f1bc9d9e9efe13791711a9ad044a4a67 Mon Sep 17 00:00:00 2001 From: autocommitter Date: Mon, 22 Apr 2024 14:52:38 +0200 Subject: State at 2021-04-04 --- Crossroads/init_code.lua | 159 ++++++++++-- Crossroads/nodes/(1100,16,1950).lua | 1 + Crossroads/nodes/(1100,20,1945).lua | 3 + Crossroads/nodes/(1116,12,2621).lua | 4 +- Crossroads/nodes/(1116,12,2653).lua | 4 +- Crossroads/nodes/(1116,23,3014).lua | 3 + Crossroads/nodes/(1116,23,3027).lua | 3 + Crossroads/nodes/(1117,16,1977).lua | 1 + Crossroads/nodes/(1117,20,1951).lua | 3 + Crossroads/nodes/(1119,16,2757).lua | 1 + Crossroads/nodes/(1119,19,3018).lua | 1 + Crossroads/nodes/(1122,16,2771).lua | 1 + Crossroads/nodes/(1171,5,846).lua | 1 + Crossroads/nodes/(1179,5,863).lua | 1 + Crossroads/nodes/(1187,-2,987).lua | 3 + Crossroads/nodes/(1187,-6,989).lua | 1 + Crossroads/nodes/(1190,-2,987).lua | 3 + Crossroads/nodes/(1190,-6,989).lua | 1 + Crossroads/nodes/(1198,-6,1006).lua | 1 + Crossroads/nodes/(1201,-6,1006).lua | 1 + Crossroads/nodes/(1223,12,1555).lua | 2 +- Crossroads/nodes/(1228,12,1541).lua | 2 +- Crossroads/nodes/(1702,5,906).lua | 6 + Crossroads/nodes/(1755,27,943).lua | 17 +- Crossroads/nodes/(1760,5,1000).lua | 6 +- Crossroads/nodes/(1786,5,994).lua | 1 + Crossroads/nodes/(1795,5,1000).lua | 6 +- Crossroads/nodes/(1801,5,1008).lua | 4 +- Crossroads/nodes/(2010,3,5938).lua | 1 + Crossroads/nodes/(30671,-6,1142).lua | 1 + Tyard/init_code.lua | 2 +- X_Nihilo/nodes/(-2716,16,962).lua | 0 X_Nihilo/nodes/(-2716,16,963).lua | 0 X_Nihilo/nodes/(-2716,16,964).lua | 0 X_Nihilo/nodes/(-2716,16,965).lua | 0 X_Nihilo/nodes/(-2716,16,966).lua | 0 X_Nihilo/nodes/(-2716,16,967).lua | 0 X_Nihilo/nodes/(-2716,16,968).lua | 0 X_Nihilo/nodes/(-2716,16,969).lua | 0 X_Nihilo/nodes/(-2716,16,970).lua | 0 X_Nihilo/nodes/(-2716,16,971).lua | 0 X_Nihilo/nodes/(-2716,16,972).lua | 0 durt/init_code.lua | 57 ++++- durt/nodes/(-1924,13,-1696).lua | 1 + durt/nodes/(-1987,13,-1700).lua | 3 + durt/nodes/(-2084,9,918).lua | 2 +- durt/nodes/(-2213,8,898).lua | 1 + durt/nodes/(-2732,11,891).lua | 0 durt/nodes/(-2734,11,891).lua | 0 durt/nodes/(-3525,8,-2281).lua | 7 +- durt/nodes/(-3544,8,-2277).lua | 2 +- durt/nodes/(-3552,16,-2275).lua | 1 + durt/nodes/(-3588,8,-2277).lua | 3 +- durt/nodes/(-3761,12,-3554).lua | 2 + durt/nodes/(-585,26,2478).lua | 2 +- durt/nodes/(-716,3,1873).lua | 3 + durt/nodes/(-716,3,1892).lua | 1 + durt/nodes/(-733,3,1854).lua | 3 + durt/nodes/(-734,3,1828).lua | 1 + durt/nodes/(1817,11,9226).lua | 1 + durt/nodes/(1819,11,9227).lua | 1 + durt/nodes/(1819,11,9233).lua | 1 + durt/nodes/(1852,8,9034).lua | 1 + durt/nodes/(1854,11,9164).lua | 1 + durt/nodes/(1856,11,9165).lua | 1 + durt/nodes/(1864,11,9161).lua | 1 + durt/nodes/(1865,17,9141).lua | 1 + durt/nodes/(1866,11,9122).lua | 1 + durt/nodes/(1874,11,9122).lua | 1 + durt/nodes/(1904,7,9133).lua | 1 + durt/nodes/(1907,9,9129).lua | 2 + durt/nodes/(1909,8,9115).lua | 5 + durt/nodes/(1914,7,9096).lua | 1 + durt/nodes/(1918,7,9099).lua | 1 + durt/nodes/(1918,7,9147).lua | 1 + durt/nodes/(1921,7,9096).lua | 1 + durt/nodes/(1921,7,9148).lua | 1 + durt/nodes/(1928,8,9112).lua | 1 + durt/nodes/(1968,39,8411).lua | 3 + durt/nodes/(431,-11,-256).lua | 9 + durt/nodes/(434,-4,-200).lua | 7 + durt/nodes/(442,-4,-198).lua | 9 + durt/nodes/(446,-4,-201).lua | 9 + durt/nodes/(771,25,8503).lua | 3 + ers/init_code.lua | 91 +++++++ ers/nodes/(1655,1,1261).lua | 30 +++ ers/nodes/(1655,1,1264).lua | 6 + ers/nodes/(3159,74,2331).lua | 0 il_timetable/init_code.lua | 453 ++++++++++++++++++++++++++++++++- il_timetable/nodes/(-1023,21,-108).lua | 1 + il_timetable/nodes/(-1023,21,-150).lua | 1 + il_timetable/nodes/(-1023,21,-190).lua | 1 + il_timetable/nodes/(-1023,21,-88).lua | 1 + il_timetable/nodes/(-1477,9,-83).lua | 29 +++ il_timetable/nodes/(-1481,3,1160).lua | 10 + il_timetable/nodes/(-2091,9,-4569).lua | 1 + il_timetable/nodes/(-640,14,-426).lua | 3 + il_timetable/nodes/(1103,23,3014).lua | 8 + il_timetable/nodes/(1103,23,3027).lua | 8 + il_timetable/nodes/(1106,19,3007).lua | 6 + il_timetable/nodes/(1106,23,1943).lua | 9 + il_timetable/nodes/(1107,16,1951).lua | 5 + il_timetable/nodes/(142,8,164).lua | 1 + il_timetable/nodes/(1524,21,2656).lua | 4 + il_timetable/nodes/(159,11,846).lua | 28 ++ il_timetable/nodes/(1604,-1,7982).lua | 10 + il_timetable/nodes/(1618,-1,7982).lua | 10 + il_timetable/nodes/(1725,28,2912).lua | 1 + il_timetable/nodes/(1730,26,2915).lua | 12 + il_timetable/nodes/(1730,26,2926).lua | 5 + il_timetable/nodes/(1734,26,2922).lua | 10 + il_timetable/nodes/(1899,19,8223).lua | 4 + il_timetable/nodes/(1932,8,9112).lua | 19 ++ il_timetable/nodes/(1936,7,9131).lua | 11 + il_timetable/nodes/(1953,19,8220).lua | 4 + il_timetable/nodes/(1971,5,7353).lua | 8 + il_timetable/nodes/(1973,42,8384).lua | 9 + il_timetable/nodes/(1973,5,6132).lua | 8 + il_timetable/nodes/(1976,5,7914).lua | 8 + il_timetable/nodes/(1977,3,7354).lua | 4 + il_timetable/nodes/(1980,3,6129).lua | 4 + il_timetable/nodes/(1980,3,7922).lua | 4 + il_timetable/nodes/(1980,41,8381).lua | 5 + il_timetable/nodes/(1980,41,8395).lua | 10 + il_timetable/nodes/(2648,13,4352).lua | 4 + il_timetable/nodes/(286,4,206).lua | 27 ++ il_timetable/nodes/(767,10,3484).lua | 10 + il_timetable/nodes/(790,8,-109).lua | 5 + il_timetable/nodes/(941,18,-571).lua | 5 + il_timetable/nodes/(957,14,1047).lua | 6 +- il_timetable/nodes/(960,14,1067).lua | 3 + il_timetable/nodes/(972,14,1053).lua | 5 +- nlvcross/init_code.lua | 1 + nlvcross/nodes/(-117,5,-1975).lua | 5 + nlvcross/nodes/(-170,7,-2008).lua | 5 + nlvcross/nodes/(1604,-1,8169).lua | 1 + nlvcross/nodes/(1607,-1,8169).lua | 1 + nlvcross/nodes/(1615,-1,8169).lua | 1 + nlvcross/nodes/(1618,-1,8169).lua | 1 + nlvcross/nodes/(1683,26,8220).lua | 1 + nlvcross/nodes/(1683,26,8223).lua | 1 + nlvcross/nodes/(572,14,1011).lua | 2 +- subway/init_code.lua | 10 +- subway/nodes/(-1559,-1,697).lua | 63 ++++- subway/nodes/(-1606,2,595).lua | 12 +- subway/nodes/(10,0,-10).lua | 2 +- subway/nodes/(305,9,34).lua | 1 - 147 files changed, 1344 insertions(+), 67 deletions(-) create mode 100644 Crossroads/nodes/(1100,16,1950).lua create mode 100644 Crossroads/nodes/(1100,20,1945).lua create mode 100644 Crossroads/nodes/(1116,23,3014).lua create mode 100644 Crossroads/nodes/(1116,23,3027).lua create mode 100644 Crossroads/nodes/(1117,16,1977).lua create mode 100644 Crossroads/nodes/(1117,20,1951).lua create mode 100644 Crossroads/nodes/(1119,16,2757).lua create mode 100644 Crossroads/nodes/(1119,19,3018).lua create mode 100644 Crossroads/nodes/(1122,16,2771).lua create mode 100644 Crossroads/nodes/(1171,5,846).lua create mode 100644 Crossroads/nodes/(1179,5,863).lua create mode 100644 Crossroads/nodes/(1187,-2,987).lua create mode 100644 Crossroads/nodes/(1187,-6,989).lua create mode 100644 Crossroads/nodes/(1190,-2,987).lua create mode 100644 Crossroads/nodes/(1190,-6,989).lua create mode 100644 Crossroads/nodes/(1198,-6,1006).lua create mode 100644 Crossroads/nodes/(1201,-6,1006).lua create mode 100644 Crossroads/nodes/(1702,5,906).lua create mode 100644 Crossroads/nodes/(1786,5,994).lua create mode 100644 Crossroads/nodes/(30671,-6,1142).lua create mode 100644 X_Nihilo/nodes/(-2716,16,962).lua create mode 100644 X_Nihilo/nodes/(-2716,16,963).lua create mode 100644 X_Nihilo/nodes/(-2716,16,964).lua create mode 100644 X_Nihilo/nodes/(-2716,16,965).lua create mode 100644 X_Nihilo/nodes/(-2716,16,966).lua create mode 100644 X_Nihilo/nodes/(-2716,16,967).lua create mode 100644 X_Nihilo/nodes/(-2716,16,968).lua create mode 100644 X_Nihilo/nodes/(-2716,16,969).lua create mode 100644 X_Nihilo/nodes/(-2716,16,970).lua create mode 100644 X_Nihilo/nodes/(-2716,16,971).lua create mode 100644 X_Nihilo/nodes/(-2716,16,972).lua create mode 100644 durt/nodes/(-1924,13,-1696).lua create mode 100644 durt/nodes/(-2213,8,898).lua create mode 100644 durt/nodes/(-2732,11,891).lua create mode 100644 durt/nodes/(-2734,11,891).lua create mode 100644 durt/nodes/(-3552,16,-2275).lua create mode 100644 durt/nodes/(-3761,12,-3554).lua create mode 100644 durt/nodes/(-716,3,1873).lua create mode 100644 durt/nodes/(-716,3,1892).lua create mode 100644 durt/nodes/(-733,3,1854).lua create mode 100644 durt/nodes/(-734,3,1828).lua create mode 100644 durt/nodes/(1817,11,9226).lua create mode 100644 durt/nodes/(1819,11,9227).lua create mode 100644 durt/nodes/(1819,11,9233).lua create mode 100644 durt/nodes/(1852,8,9034).lua create mode 100644 durt/nodes/(1854,11,9164).lua create mode 100644 durt/nodes/(1856,11,9165).lua create mode 100644 durt/nodes/(1864,11,9161).lua create mode 100644 durt/nodes/(1865,17,9141).lua create mode 100644 durt/nodes/(1866,11,9122).lua create mode 100644 durt/nodes/(1874,11,9122).lua create mode 100644 durt/nodes/(1904,7,9133).lua create mode 100644 durt/nodes/(1907,9,9129).lua create mode 100644 durt/nodes/(1909,8,9115).lua create mode 100644 durt/nodes/(1914,7,9096).lua create mode 100644 durt/nodes/(1918,7,9099).lua create mode 100644 durt/nodes/(1918,7,9147).lua create mode 100644 durt/nodes/(1921,7,9096).lua create mode 100644 durt/nodes/(1921,7,9148).lua create mode 100644 durt/nodes/(1928,8,9112).lua create mode 100644 durt/nodes/(1968,39,8411).lua create mode 100644 durt/nodes/(431,-11,-256).lua create mode 100644 durt/nodes/(434,-4,-200).lua create mode 100644 durt/nodes/(442,-4,-198).lua create mode 100644 durt/nodes/(446,-4,-201).lua create mode 100644 durt/nodes/(771,25,8503).lua create mode 100644 ers/init_code.lua create mode 100644 ers/nodes/(1655,1,1261).lua create mode 100644 ers/nodes/(1655,1,1264).lua create mode 100644 ers/nodes/(3159,74,2331).lua create mode 100644 il_timetable/nodes/(-1023,21,-108).lua create mode 100644 il_timetable/nodes/(-1023,21,-150).lua create mode 100644 il_timetable/nodes/(-1023,21,-190).lua create mode 100644 il_timetable/nodes/(-1023,21,-88).lua create mode 100644 il_timetable/nodes/(-1477,9,-83).lua create mode 100644 il_timetable/nodes/(-1481,3,1160).lua create mode 100644 il_timetable/nodes/(-2091,9,-4569).lua create mode 100644 il_timetable/nodes/(-640,14,-426).lua create mode 100644 il_timetable/nodes/(1103,23,3014).lua create mode 100644 il_timetable/nodes/(1103,23,3027).lua create mode 100644 il_timetable/nodes/(1106,19,3007).lua create mode 100644 il_timetable/nodes/(1106,23,1943).lua create mode 100644 il_timetable/nodes/(1107,16,1951).lua create mode 100644 il_timetable/nodes/(142,8,164).lua create mode 100644 il_timetable/nodes/(1524,21,2656).lua create mode 100644 il_timetable/nodes/(159,11,846).lua create mode 100644 il_timetable/nodes/(1604,-1,7982).lua create mode 100644 il_timetable/nodes/(1618,-1,7982).lua create mode 100644 il_timetable/nodes/(1725,28,2912).lua create mode 100644 il_timetable/nodes/(1730,26,2915).lua create mode 100644 il_timetable/nodes/(1730,26,2926).lua create mode 100644 il_timetable/nodes/(1734,26,2922).lua create mode 100644 il_timetable/nodes/(1899,19,8223).lua create mode 100644 il_timetable/nodes/(1932,8,9112).lua create mode 100644 il_timetable/nodes/(1936,7,9131).lua create mode 100644 il_timetable/nodes/(1953,19,8220).lua create mode 100644 il_timetable/nodes/(1971,5,7353).lua create mode 100644 il_timetable/nodes/(1973,42,8384).lua create mode 100644 il_timetable/nodes/(1973,5,6132).lua create mode 100644 il_timetable/nodes/(1976,5,7914).lua create mode 100644 il_timetable/nodes/(1977,3,7354).lua create mode 100644 il_timetable/nodes/(1980,3,6129).lua create mode 100644 il_timetable/nodes/(1980,3,7922).lua create mode 100644 il_timetable/nodes/(1980,41,8381).lua create mode 100644 il_timetable/nodes/(1980,41,8395).lua create mode 100644 il_timetable/nodes/(2648,13,4352).lua create mode 100644 il_timetable/nodes/(286,4,206).lua create mode 100644 il_timetable/nodes/(767,10,3484).lua create mode 100644 il_timetable/nodes/(790,8,-109).lua create mode 100644 il_timetable/nodes/(941,18,-571).lua create mode 100644 il_timetable/nodes/(960,14,1067).lua create mode 100644 nlvcross/nodes/(-117,5,-1975).lua create mode 100644 nlvcross/nodes/(-170,7,-2008).lua create mode 100644 nlvcross/nodes/(1604,-1,8169).lua create mode 100644 nlvcross/nodes/(1607,-1,8169).lua create mode 100644 nlvcross/nodes/(1615,-1,8169).lua create mode 100644 nlvcross/nodes/(1618,-1,8169).lua create mode 100644 nlvcross/nodes/(1683,26,8220).lua create mode 100644 nlvcross/nodes/(1683,26,8223).lua diff --git a/Crossroads/init_code.lua b/Crossroads/init_code.lua index ce984ab..dc8cf08 100644 --- a/Crossroads/init_code.lua +++ b/Crossroads/init_code.lua @@ -1,5 +1,13 @@ +F.foo = {} +function F.foo2() + F.foo[1] = "foo" +end + if S.trains == nil then S.trains = {} end if not S.odsd then S.odsd = {} end +if not S.cpoints then S.cpoints = {} end +S.pd = {} +S.pdt = {} F.odj = {} @@ -116,6 +124,7 @@ end -- Second version of the station function function F.stn2gen(stn, trk, door, ret, chout) + __approach_callback_mode = 1 if not stn then return end if not trk then return end if not door then return end @@ -129,20 +138,38 @@ function F.stn2gen(stn, trk, door, ret, chout) local l = get_line() if (not l) or l==" " then return end local rc = get_rc() or "" - if rc:match("FREIGHT") then + if rc:match("FREIGHT") and atc_id then atc_send (ret and "BBWRSM" or "SM") return end - if event.type == "train" then + if event.type == "approach" then + for i = 1, #t, 1 do + if t[i][1]==l then + atc_set_lzb_tsr(2) + return + end + end + return + elseif 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 timenow = os.time() + local interval = F.lines[l].interval + local offset = t[i][7] + local arroff + if interval and offset then + arroff = timenow%interval + interval = (offset-timenow)%interval + interval = math.max(10, math.min(45, interval)) + else + interval = 15 + end + atc_send(string.format("A0B0WO%sD%dOCD1%sA1SM", door, interval, (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 intext = ("%s\n%s\nDebug: %d %d"):format(F.stnlist[stn] or stn, intext_nxt, arroff or timenow, interval) 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]) @@ -155,19 +182,17 @@ function F.stn2gen(stn, trk, door, ret, chout) s = stn, t = (trk or "N/A"), } - schedule_in(15, intext_nxt) + schedule_in(interval) break end end if (not stop) then atc_send(ret and "BBWRSM" or "SM") end - end - 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]] + elseif event.type == "schedule" then + if atc_id then + atc_send("OCD1"..(((not ret) == (not atc_arrow)) and "R" or "").."A1SM") + end end end @@ -176,7 +201,11 @@ function F.disp2gen(stn) if not F.stndet[stn] then return end local s = F.stndet[stn] 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 d={{ + {sn.."\nTrack Line"}, + {(string.sub(sn, 28, 54) or "").." \nDestination"}, + {" \nEstimated Arrival"} + }} local c=2 local t={} for i,_ in pairs(s) do t[#t+1]=i end @@ -187,17 +216,59 @@ function F.disp2gen(stn) for j = 1,#trk,1 do local det = trk[j] local r = (c%4==0) and (c/4+1) or ((c-c%4)/4+1) - if not d[r] then d[r]={"",""} end - 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" + if not d[r] then d[r]={{},{},{}} end + 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] .. os.date("%Y-%m-%d %H:%M %Z", earr) .. "\n" + d[r][3][#d[r][3]+1] = os.date("%Y-%m-%d %H:%M %Z", earr) end end for i = 1, #d, 1 do - for j = 1, #d[1], 1 do - digiline_send("d_"..tostring(i).."_"..tostring(j), d[i][j]) + for j = 1, #d[i], 1 do + digiline_send("d_"..tostring(i).."_"..tostring(j), table.concat(d[i][j],"\n")) + end + end +end + +--function F.disp2gen() end + +function F.pdisp(stn, trk, dn) + if not (stn and trk and dn) then return end + if not F.stndet[stn] or not F.stndet[stn][trk] then return end + if not S.pd[stn] then S.pd[stn] = { [trk] = {[dn] = 0} } end + if not S.pd[stn][trk] then S.pd[stn][trk] = {[dn] = 0} end + if not S.pd[stn][trk][dn] then S.pd[stn][trk][dn] = 0 end + if not S.pdt[stn] then S.pdt[stn] = {} end + if not S.pdt[stn][trk] then + local t = {} + for i = 1, #F.stndet[stn][trk], 1 do + local v = F.stndet[stn][trk][i] + t[#t+1] = ("Track: %s\n%s\nTo: %s\nNext: %s"):format( + trk, F.lines[v[1]].name, F.stnlist[v[4] or "N/A"] or v[4] or "N/A", + F.stnlist[v[2] or "N/A"] or v[2] or "N/A") + end + S.pdt[stn][trk] = t + end + local n = S.pd[stn][trk][dn] + 1 + local t = S.pdt[stn][trk] + digiline_send("track"..trk,t[n]) + if n >= #t then n = 0 end + S.pd[stn][trk][dn] = n +end + +function F.dirsign(stn, trk, ln, arrow) + if event.type == "init" or event.type == "punch" then + if not (stn and trk and ln and arrow) then return end + local t = F.stndet[stn] + if not t then return end + t = t[trk] + if not t then return end + for i = 1, #t, 1 do + if t[i][1] == ln then + digiline_send("lcd",("%s T. %s | %s | %s"):format(arrow, trk, F.lines[ln].name, F.stnlist[t[i][4]])) + break + end end end end @@ -234,6 +305,8 @@ function F.atc (cmd, intext, outtext) end F.stnlist = { + ["N/A"] = "N/A", + Bts = "Origin Berton St.", cg = "Colored Grasses", clockwise = "Clockwise Route", counterclockwise = "Counterclockwise Route", @@ -276,16 +349,25 @@ F.stnlist = { F.lines = { ["AB"] = { - name = "ATL Bronze Line", + name = "ATL-B Commuter", short = "ATL-B/C", + ring = false, + interval = 240, + [1] = { {"crch","A1"}, --[[ {"crwm","3"},]] {"scs","N1"}, {"scc","N1"}, {"scn","N1"}, {"cg","1"}, {"thecube","4"}, --[[{"phsc","N"},]] {"grsc", "4"}, {"phwest","2"} }, + [2] = { {"phwest","2"}, {"grsc", "3"}, --[[{"phsc","S"},]] {"thecube","1"}, {"cg","2"}, {"scn","S1"}, {"scc","S1"}, {"scs","S1"}, --[[ {"crwm","4"}, ]] {"crch","A1"} }, + }, + ["ABE"] = { + name = "ATL-B Express", short = "ATL-B/E", ring = false, - [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"} }, + interval = 240, + [1] = {{"crch","A1"}, {"scc","N2"}, {"cg","1"}, {"thecube", "4"}, {"phwest", "2"}}, + [2] = {{"phwest", "2"}, {"thecube", "1"}, {"cg", "2"}, {"scc", "S2"}, {"crch", "A1"}}, }, ["AZ"] = { - name = "ATL Zinc Line", + name = "ATL Zinc Line", short = "ATL-Z", ring = false, - [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"} }, + interval = 480, + [1] = { {"Bts","3"}, {"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"}, {"Bts","3"}, }, }, ["CRT1"] = { name = "CRT 1", @@ -308,15 +390,17 @@ for i, l in pairs(F.lines) do for k = 1, #dir, 1 do local s = dir[k][1] local t = dir[k][2] + local o = dir[k][3] 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] - F.stndet[s][t][#F.stndet[s][t]+1] = {i, nxt[1], nxt[2], dir[#dir][1]} + det[#det+1] = {i, nxt[1], nxt[2], dir[#dir][1], nil, nil, o} else local addent = true for m = 1, #l, 1 do addent = addent and (l[m][1]==dir[k]) end - if addent then F.stndet[s][t][#F.stndet[s][t]+1] = {i, nil, nil, s} end + if addent then det[#det+1] = {i, nil, nil, s, nil, nil, o} end end end end @@ -385,4 +469,25 @@ end function F.odc(ln, rc) interrupt_pos(F.dpts[ln],{['rc']=rc}) +end + +function F.cpoint(name, int) + __approach_callback_mode = 1 + local last = S.cpoints[name] or 0 + local next = last+int + local now = os.time() + if event.type == "approach" then + if now < next then atc_set_lzb_tsr(2) end + elseif event.type == "train" and atc_arrow then + if now < next then + atc_send(string.format("A0B0WD%dA1SM", next-now)) + schedule_in(next-now) + else + S.cpoints[name] = now + atc_send("A1SM") + end + elseif event.type == "schedule" and atc_arrow then + S.cpoints[name] = now + atc_send("A1SM") + end end \ No newline at end of file diff --git a/Crossroads/nodes/(1100,16,1950).lua b/Crossroads/nodes/(1100,16,1950).lua new file mode 100644 index 0000000..194c3d9 --- /dev/null +++ b/Crossroads/nodes/(1100,16,1950).lua @@ -0,0 +1 @@ +F.stn2gen("thecube","1","L") \ No newline at end of file diff --git a/Crossroads/nodes/(1100,20,1945).lua b/Crossroads/nodes/(1100,20,1945).lua new file mode 100644 index 0000000..0cdeadc --- /dev/null +++ b/Crossroads/nodes/(1100,20,1945).lua @@ -0,0 +1,3 @@ +if event.type == "digiline" and event.channel == "t1" then + F.pdisp("thecube","1","S") +end \ No newline at end of file diff --git a/Crossroads/nodes/(1116,12,2621).lua b/Crossroads/nodes/(1116,12,2621).lua index 3b6577d..1267653 100644 --- a/Crossroads/nodes/(1116,12,2621).lua +++ b/Crossroads/nodes/(1116,12,2621).lua @@ -1 +1,3 @@ -F.disp2gen("phsc") \ No newline at end of file +if event.type == "digiline" and event.channel == "upd" then + F.disp2gen("phsc") +end \ No newline at end of file diff --git a/Crossroads/nodes/(1116,12,2653).lua b/Crossroads/nodes/(1116,12,2653).lua index 3b6577d..1267653 100644 --- a/Crossroads/nodes/(1116,12,2653).lua +++ b/Crossroads/nodes/(1116,12,2653).lua @@ -1 +1,3 @@ -F.disp2gen("phsc") \ No newline at end of file +if event.type == "digiline" and event.channel == "upd" then + F.disp2gen("phsc") +end \ No newline at end of file diff --git a/Crossroads/nodes/(1116,23,3014).lua b/Crossroads/nodes/(1116,23,3014).lua new file mode 100644 index 0000000..44e9c85 --- /dev/null +++ b/Crossroads/nodes/(1116,23,3014).lua @@ -0,0 +1,3 @@ +if event.type == "digiline" and event.channel == "track2-update" then + F.pdisp("phwest","2","S") +end \ No newline at end of file diff --git a/Crossroads/nodes/(1116,23,3027).lua b/Crossroads/nodes/(1116,23,3027).lua new file mode 100644 index 0000000..4902e0c --- /dev/null +++ b/Crossroads/nodes/(1116,23,3027).lua @@ -0,0 +1,3 @@ +if event.type == "digiline" and event.channel == "track2-update" then + F.pdisp("phwest","2","N") +end \ No newline at end of file diff --git a/Crossroads/nodes/(1117,16,1977).lua b/Crossroads/nodes/(1117,16,1977).lua new file mode 100644 index 0000000..29aeb3f --- /dev/null +++ b/Crossroads/nodes/(1117,16,1977).lua @@ -0,0 +1 @@ +F.stn2gen("thecube","4","L") \ No newline at end of file diff --git a/Crossroads/nodes/(1117,20,1951).lua b/Crossroads/nodes/(1117,20,1951).lua new file mode 100644 index 0000000..a17606a --- /dev/null +++ b/Crossroads/nodes/(1117,20,1951).lua @@ -0,0 +1,3 @@ +if event.type == "digiline" and event.channel == "t4" then + F.pdisp("thecube","4","S") +end \ No newline at end of file diff --git a/Crossroads/nodes/(1119,16,2757).lua b/Crossroads/nodes/(1119,16,2757).lua new file mode 100644 index 0000000..dde01ed --- /dev/null +++ b/Crossroads/nodes/(1119,16,2757).lua @@ -0,0 +1 @@ +F.stn2gen("grsc", "3", "R") \ No newline at end of file diff --git a/Crossroads/nodes/(1119,19,3018).lua b/Crossroads/nodes/(1119,19,3018).lua new file mode 100644 index 0000000..51ef14b --- /dev/null +++ b/Crossroads/nodes/(1119,19,3018).lua @@ -0,0 +1 @@ +F.stn2gen("phwest","2","L",true,true) \ No newline at end of file diff --git a/Crossroads/nodes/(1122,16,2771).lua b/Crossroads/nodes/(1122,16,2771).lua new file mode 100644 index 0000000..27a6f78 --- /dev/null +++ b/Crossroads/nodes/(1122,16,2771).lua @@ -0,0 +1 @@ +F.stn2gen("grsc", "4", "R") \ No newline at end of file diff --git a/Crossroads/nodes/(1171,5,846).lua b/Crossroads/nodes/(1171,5,846).lua new file mode 100644 index 0000000..354d229 --- /dev/null +++ b/Crossroads/nodes/(1171,5,846).lua @@ -0,0 +1 @@ +F.stn2gen("scs","S1","R") \ No newline at end of file diff --git a/Crossroads/nodes/(1179,5,863).lua b/Crossroads/nodes/(1179,5,863).lua new file mode 100644 index 0000000..61b92a5 --- /dev/null +++ b/Crossroads/nodes/(1179,5,863).lua @@ -0,0 +1 @@ +F.stn2gen("scs","N1","R") \ No newline at end of file diff --git a/Crossroads/nodes/(1187,-2,987).lua b/Crossroads/nodes/(1187,-2,987).lua new file mode 100644 index 0000000..d4e994b --- /dev/null +++ b/Crossroads/nodes/(1187,-2,987).lua @@ -0,0 +1,3 @@ +if event.type == "digiline" and event.channel == "upd" then + F.pdisp("scc","S2","S") +end \ No newline at end of file diff --git a/Crossroads/nodes/(1187,-6,989).lua b/Crossroads/nodes/(1187,-6,989).lua new file mode 100644 index 0000000..5c86126 --- /dev/null +++ b/Crossroads/nodes/(1187,-6,989).lua @@ -0,0 +1 @@ +F.stn2gen("scc", "S2", "R") \ No newline at end of file diff --git a/Crossroads/nodes/(1190,-2,987).lua b/Crossroads/nodes/(1190,-2,987).lua new file mode 100644 index 0000000..3722041 --- /dev/null +++ b/Crossroads/nodes/(1190,-2,987).lua @@ -0,0 +1,3 @@ +if event.type == "digiline" and event.channel == "upd" then + F.pdisp("scc","S1","S") +end \ No newline at end of file diff --git a/Crossroads/nodes/(1190,-6,989).lua b/Crossroads/nodes/(1190,-6,989).lua new file mode 100644 index 0000000..3947016 --- /dev/null +++ b/Crossroads/nodes/(1190,-6,989).lua @@ -0,0 +1 @@ +F.stn2gen("scc", "S1", "L") \ No newline at end of file diff --git a/Crossroads/nodes/(1198,-6,1006).lua b/Crossroads/nodes/(1198,-6,1006).lua new file mode 100644 index 0000000..c0c450e --- /dev/null +++ b/Crossroads/nodes/(1198,-6,1006).lua @@ -0,0 +1 @@ +F.stn2gen("scc", "N1", "L") \ No newline at end of file diff --git a/Crossroads/nodes/(1201,-6,1006).lua b/Crossroads/nodes/(1201,-6,1006).lua new file mode 100644 index 0000000..855f755 --- /dev/null +++ b/Crossroads/nodes/(1201,-6,1006).lua @@ -0,0 +1 @@ +F.stn2gen("scc", "N2", "R") \ No newline at end of file diff --git a/Crossroads/nodes/(1223,12,1555).lua b/Crossroads/nodes/(1223,12,1555).lua index b07a528..75d5eea 100644 --- a/Crossroads/nodes/(1223,12,1555).lua +++ b/Crossroads/nodes/(1223,12,1555).lua @@ -1,5 +1,5 @@ if event.type == "digiline" then if event.channel == "updwrapper" then - digiline_send("upd","update") + F.disp2gen("cg") end end \ No newline at end of file diff --git a/Crossroads/nodes/(1228,12,1541).lua b/Crossroads/nodes/(1228,12,1541).lua index b07a528..75d5eea 100644 --- a/Crossroads/nodes/(1228,12,1541).lua +++ b/Crossroads/nodes/(1228,12,1541).lua @@ -1,5 +1,5 @@ if event.type == "digiline" then if event.channel == "updwrapper" then - digiline_send("upd","update") + F.disp2gen("cg") end end \ No newline at end of file diff --git a/Crossroads/nodes/(1702,5,906).lua b/Crossroads/nodes/(1702,5,906).lua new file mode 100644 index 0000000..03259d6 --- /dev/null +++ b/Crossroads/nodes/(1702,5,906).lua @@ -0,0 +1,6 @@ +__approach_callback_mode = 1 +if event.type == "approach" then + atc_set_lzb_tsr(2) +elseif event.type == "train" then + atc_send("B2") +end \ No newline at end of file diff --git a/Crossroads/nodes/(1755,27,943).lua b/Crossroads/nodes/(1755,27,943).lua index d09f055..135d7ab 100644 --- a/Crossroads/nodes/(1755,27,943).lua +++ b/Crossroads/nodes/(1755,27,943).lua @@ -1,7 +1,8 @@ -local head = { "V TRAIN LINE STATION", " " } +local head = { "V TRAIN LINE STATION ", " " } local length = 18 if event.type=="digiline" or event.type=="punch" then if event.channel=="upd_main" or event.type=="punch" then + local table = table local start_t = os.clock() if not S.lagrec then S.lagrec = {} end local la = {} @@ -14,16 +15,16 @@ if event.type=="digiline" or event.type=="punch" then for id = 1, #ids, 1 do local st = (S.trains[ids[id] or 0] or "") i = (counter-counter%7)/7*2+((counter%7<3) and 1 or 2) - if not la[i] then la[i] = (i%2==0) and "" or head[1] end - if not lb[i] then lb[i] = (i%2==0) and "" or head[2] end - local n = "[" .. (st.t or "N/A") .. "] " .. (F.stnlist[st.s] or st.s) - la[i] = string.format ("%s\n%02d %06d %-7s %s", la[i], st.v, ids[id], st.l, n) - lb[i] = lb[i] .. "\n" .. (n:len() < 10 and " " or n:sub(10)) + if not la[i] then la[i] = (i%2==0) and {} or {head[1]} end + if not lb[i] then lb[i] = (i%2==0) and {} or {head[2]} end + local n = string.format("[%s] %s", st.t or "?", F.stnlist[st.s] or st.s) + la[i][#la[i]+1] = string.format("%02d %06d %-7s %s", st.v, ids[id], st.l, n) + lb[i][#lb[i]+1] = (n:len() < 10 and " " or n:sub(10)) counter = counter + 1 end for i=1,#la,1 do - digiline_send("d"..tostring(i).."a", la[i] or "") - digiline_send("d"..tostring(i).."b", lb[i] or "") + digiline_send("d"..tostring(i).."a", table.concat(la[i] or {" "," "},"\n")) + digiline_send("d"..tostring(i).."b", table.concat(lb[i] or {" "," "},"\n")) end local end_t = os.clock() S.lagrec[#S.lagrec+1] = end_t - start_t diff --git a/Crossroads/nodes/(1760,5,1000).lua b/Crossroads/nodes/(1760,5,1000).lua index ccb559e..7489acc 100644 --- a/Crossroads/nodes/(1760,5,1000).lua +++ b/Crossroads/nodes/(1760,5,1000).lua @@ -1,5 +1 @@ -if event.type=='train' then - if atc_arrow then - atc_set_text_outside('ATL Mithril Line - Ehlodex') - end -end \ No newline at end of file +-- \ No newline at end of file diff --git a/Crossroads/nodes/(1786,5,994).lua b/Crossroads/nodes/(1786,5,994).lua new file mode 100644 index 0000000..e701f62 --- /dev/null +++ b/Crossroads/nodes/(1786,5,994).lua @@ -0,0 +1 @@ +F.stn2gen("crch", "A1", "R", true, true) \ No newline at end of file diff --git a/Crossroads/nodes/(1795,5,1000).lua b/Crossroads/nodes/(1795,5,1000).lua index d5beb66..7489acc 100644 --- a/Crossroads/nodes/(1795,5,1000).lua +++ b/Crossroads/nodes/(1795,5,1000).lua @@ -1,5 +1 @@ -if event.type == "train" then - if atc_arrow then - atc_set_text_inside("Next stop: CR-North Station St. 9th Alley") - end -end \ No newline at end of file +-- \ No newline at end of file diff --git a/Crossroads/nodes/(1801,5,1008).lua b/Crossroads/nodes/(1801,5,1008).lua index 7741b35..72e6533 100644 --- a/Crossroads/nodes/(1801,5,1008).lua +++ b/Crossroads/nodes/(1801,5,1008).lua @@ -1,5 +1,5 @@ -if event.type == "train" then +--[[if event.type == "train" then if atc_arrow then atc_set_text_outside("ATL Mithril Line - Ehlodex") end -end \ No newline at end of file +end]] \ No newline at end of file diff --git a/Crossroads/nodes/(2010,3,5938).lua b/Crossroads/nodes/(2010,3,5938).lua index 99bcc37..4716a64 100644 --- a/Crossroads/nodes/(2010,3,5938).lua +++ b/Crossroads/nodes/(2010,3,5938).lua @@ -1,3 +1,4 @@ +do return end if event.type == "punch" then for i = 1, 4, 1 do cancel_route("mary4-testsignal-"..tostring(i)) diff --git a/Crossroads/nodes/(30671,-6,1142).lua b/Crossroads/nodes/(30671,-6,1142).lua new file mode 100644 index 0000000..a333ad4 --- /dev/null +++ b/Crossroads/nodes/(30671,-6,1142).lua @@ -0,0 +1 @@ +F.cpoint("wbx-ind", 300) \ No newline at end of file diff --git a/Tyard/init_code.lua b/Tyard/init_code.lua index 99b63e4..91bf2b0 100644 --- a/Tyard/init_code.lua +++ b/Tyard/init_code.lua @@ -2,4 +2,4 @@ S.single_dir = true -F.EOL = function(direction,lane) if S.yard_active then if S.dir == direction then if atc_arrow then if not S.exiting then --return to PICKUP via headshunt split_off_locomotive("B0WR") set_rc("PICKUP") set_route("TY"..direction.."_"..lane, "HEADSHUNT") else --if S.exiting then loco has already sorted to correct lane for departure --S.exiting set by the pickup track set_rc(S.rc) set_route("TY"..direction.."_"..lane, "EXIT") S.exiting = nil end end else -- preparing for bi-directional. also EOL Bounce atc_send("B0WD1RS4") end end end \ No newline at end of file +F.EOL = function(direction,lane) if S.yard_active then if S.dir == direction then if atc_arrow then if not S.exiting then --return to PICKUP via headshunt split_off_locomotive("B0WR") set_rc("PICKUP") set_route("TY"..direction.."_"..lane, "HEADSHUNT") else --if S.exiting then loco has already sorted to correct lane for departure --S.exiting set by the pickup track set_rc(S.rc) set_route("TY"..direction.."_"..lane, "EXIT") S.exiting = nil end end else -- preparing for bi-directional. also EOL Bounce atc_send("B0WD1RS4") end end end \ No newline at end of file diff --git a/X_Nihilo/nodes/(-2716,16,962).lua b/X_Nihilo/nodes/(-2716,16,962).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,963).lua b/X_Nihilo/nodes/(-2716,16,963).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,964).lua b/X_Nihilo/nodes/(-2716,16,964).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,965).lua b/X_Nihilo/nodes/(-2716,16,965).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,966).lua b/X_Nihilo/nodes/(-2716,16,966).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,967).lua b/X_Nihilo/nodes/(-2716,16,967).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,968).lua b/X_Nihilo/nodes/(-2716,16,968).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,969).lua b/X_Nihilo/nodes/(-2716,16,969).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,970).lua b/X_Nihilo/nodes/(-2716,16,970).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,971).lua b/X_Nihilo/nodes/(-2716,16,971).lua new file mode 100644 index 0000000..e69de29 diff --git a/X_Nihilo/nodes/(-2716,16,972).lua b/X_Nihilo/nodes/(-2716,16,972).lua new file mode 100644 index 0000000..e69de29 diff --git a/durt/init_code.lua b/durt/init_code.lua index c264a3a..af89c7c 100644 --- a/durt/init_code.lua +++ b/durt/init_code.lua @@ -11,4 +11,59 @@ S.M27_tracking = {} -- -3602,18,-3961 Willow Tunnel <-> Djnc -- -3602.18.-3961 Djnc<->Dcaves -- -2345,15,-1336 Tanh Depot -- -1986,13,-1699 x2 Foundry entry -F.M27_tracking = function(id) if not event.train then return end local rc = get_rc() or "" if not rc:match("M27_tracking") then return end S.M27_tracking.last = S.M27_tracking.now S.M27_tracking.now = id end --------------------------------------------------------------------- --defining the functions F.arrive = function(stn_code,dir,line) S.lines[line].monitoring[dir][stn_code] = atc_id atc_send("B0 W O"..S.lines[line].stations[stn_code].doors) atc_set_text_inside("Arrived at:\n"..S.lines[line].stations[stn_code].name.."\n \nNext Station:\n"..S.lines[line].stations[S.lines[line].stations[stn_code].next_station[dir]].name) end F.depart = function(stn_code,dir,line) local pos = stn_code..dir local inside_text = "Next Stop:\n"..S.lines[line].stations[S.lines[line].stations[stn_code].next_station[dir]].name if can_set_route(pos,stn_code.."->"..S.lines[line].stations[stn_code].next_station[dir]) then set_route(pos,stn_code.."->"..S.lines[line].stations[stn_code].next_station[dir]) atc_send("OC SM") S.lines[line].monitoring[dir][stn_code] = nil S.lines[line].monitoring[dir][S.lines[line].stations[stn_code].next_station[dir]] = atc_id else -- Wait another 5s before trying again inside_text = inside_text.."\nWaiting to depart..." interrupt(5, "depart") end atc_set_text_inside(inside_text) end F.set_desto = function(dir, line) atc_set_text_outside("LINE " .. line .."\n---> " .. S.lines[line].stations[S.lines[line].termini[dir]].name) end --------------------------------------------------------------------- --LuaATC track functions F.station = function(stn_code,dir,line) -- temp until all SF LuaAtc tracks are changed------------------------- if line == nil or line == "1" then line = "U21" end --------------------------------------------------------------------- if event.train then F.arrive(stn_code,dir,line) interrupt(10,"depart") elseif event.int and event.msg=="depart" then F.depart(stn_code,dir,line) end end F.terminus = function(stn_code, newdir, line) if event.train then S.lines[line].monitoring[newdir][stn_code] = atc_id atc_send("B0 W R O"..S.lines[line].stations[stn_code].doors) atc_set_text_inside("Arrived at:\n"..S.lines[line].stations[stn_code].name.."\n \nNext Station:\n"..S.lines[line].stations[S.lines[line].stations[stn_code].next_station[newdir]].name) atc_set_text_outside("LINE " .. line .."\n---> " .. S.lines[line].stations[S.lines[line].termini[newdir]].name) interrupt(10, "depart") end if event.int and event.msg == "depart" then F.depart(stn_code, newdir,line) end end \ No newline at end of file +F.M27_tracking = function(id) if not event.train then return end local rc = get_rc() or "" if not rc:match("M27_tracking") then return end S.M27_tracking.last = S.M27_tracking.now S.M27_tracking.now = id end + +--Atlac Yard Operations +if event.init then + local list_of_yards = { + ["WOA"] = {} + } + S.yards = S.yards or list_of_yards +end + +F.yard_road_count = function(yard,section_id,monitoring_light) if not S.yards[yard][section_id] then S.yards[yard][section_id] = {['car_count'] = 0} end local car_count = S.yards[yard][section_id].car_count if event.train then if atc_arrow then --arrow points into section, add to length car_count = car_count + train_length() else -- subtract from car_count = car_count - train_length() end if car_count > 0 then -- light = on setstate(monitoring_light,"on") else car_count = 0 setstate(monitoring_light,"off") end S.yards[yard][section_id].car_count = car_count end end + + +--stats counter from subway/il_timetable +F.stat=function(line, init) +--statistics +-- init +if init then +reftrain = atc_id +a_tbt = 30 +a_tbtmax = 30 +a_rtt = 500 +a_not = 0 +c_not = 0 +c_tbtmax = 0 +time_lt = os.time() +time_rt=os.time() +end +if not a_tbtmax then a_tbtmax = 30 end +if not c_tbtmax then c_tbtmax = 0 end +--real code +if event.train then +local time = os.time() +c_not = c_not + 1 +a_tbt = (a_tbt + (time - time_lt)) / 2 +c_tbtmax = math.max(c_tbtmax, (time - time_lt)) +if atc_id == reftrain then + a_rtt = (a_rtt*0.2 + (time - time_rt)*0.8) + a_not = c_not + c_not = 0 + a_tbtmax = (a_tbtmax + c_tbtmax) / 2 + c_tbtmax = 0 +end + digiline_send("stats", "Stat: "..line.. + " NoT:"..a_not.."("..c_not..")".. + " TbT:"..math.floor(a_tbt).."("..(time-time_lt)..")".. + " Tmx:"..math.floor(a_tbtmax).."("..c_tbtmax..")".. + " R:"..math.floor(a_rtt).."("..(time - time_rt)..")" + ) +time_lt = time +if atc_id == reftrain then + time_rt = time +end +end +end + --------------------------------------------------------------------- --defining the functions F.arrive = function(stn_code,dir,line) S.lines[line].monitoring[dir][stn_code] = atc_id atc_send("B0 W O"..S.lines[line].stations[stn_code].doors) atc_set_text_inside("Arrived at:\n"..S.lines[line].stations[stn_code].name.."\n \nNext Station:\n"..S.lines[line].stations[S.lines[line].stations[stn_code].next_station[dir]].name) end F.depart = function(stn_code,dir,line) local pos = stn_code..dir local inside_text = "Next Stop:\n"..S.lines[line].stations[S.lines[line].stations[stn_code].next_station[dir]].name if can_set_route(pos,stn_code.."->"..S.lines[line].stations[stn_code].next_station[dir]) then set_route(pos,stn_code.."->"..S.lines[line].stations[stn_code].next_station[dir]) atc_send("OC SM") S.lines[line].monitoring[dir][stn_code] = nil S.lines[line].monitoring[dir][S.lines[line].stations[stn_code].next_station[dir]] = atc_id else -- Wait another 5s before trying again inside_text = inside_text.."\nWaiting to depart..." interrupt(5, "depart") end atc_set_text_inside(inside_text) end F.set_desto = function(dir, line) atc_set_text_outside("LINE " .. line .."\n---> " .. S.lines[line].stations[S.lines[line].termini[dir]].name) end --------------------------------------------------------------------- --LuaATC track functions F.station = function(stn_code,dir,line) -- temp until all SF LuaAtc tracks are changed------------------------- if line == nil or line == "1" then line = "U21" end --------------------------------------------------------------------- if event.train then F.arrive(stn_code,dir,line) interrupt(10,"depart") elseif event.int and event.msg=="depart" then F.depart(stn_code,dir,line) end end F.terminus = function(stn_code, newdir, line) if event.train then S.lines[line].monitoring[newdir][stn_code] = atc_id atc_send("B0 W R O"..S.lines[line].stations[stn_code].doors) atc_set_text_inside("Arrived at:\n"..S.lines[line].stations[stn_code].name.."\n \nNext Station:\n"..S.lines[line].stations[S.lines[line].stations[stn_code].next_station[newdir]].name) atc_set_text_outside("LINE " .. line .."\n---> " .. S.lines[line].stations[S.lines[line].termini[newdir]].name) interrupt(10, "depart") end if event.int and event.msg == "depart" then F.depart(stn_code, newdir,line) end end \ No newline at end of file diff --git a/durt/nodes/(-1924,13,-1696).lua b/durt/nodes/(-1924,13,-1696).lua new file mode 100644 index 0000000..74c05cc --- /dev/null +++ b/durt/nodes/(-1924,13,-1696).lua @@ -0,0 +1 @@ +__approach_callback_mode = 1 if not atc_id or not atc_arrow then return end if event.approach and not event.has_entered then atc_set_lzb_tsr(2) end if event.train and atc_arrow then atc_send("S1") end \ No newline at end of file diff --git a/durt/nodes/(-1987,13,-1700).lua b/durt/nodes/(-1987,13,-1700).lua index 00818fd..fc6a367 100644 --- a/durt/nodes/(-1987,13,-1700).lua +++ b/durt/nodes/(-1987,13,-1700).lua @@ -1 +1,4 @@ +if event.train and atc_arrow and atc_speed == 1 then + atc_send("SM") +end F.M27_tracking("Exit Foundry") \ No newline at end of file diff --git a/durt/nodes/(-2084,9,918).lua b/durt/nodes/(-2084,9,918).lua index ae8e76f..dbf9fcf 100644 --- a/durt/nodes/(-2084,9,918).lua +++ b/durt/nodes/(-2084,9,918).lua @@ -1 +1 @@ -if event.type=="digiline" then if event.channel ~= "trainctl" then return end if event.msg == "send" then setstate(POS(-2085,11,918),"green") if atc_id and atc_arrow then atc_send("B5S5") elseif atc_id and atc_arrow == false then atc_send("B0S0WRS5") end interrupt(10,"clear_signal") return elseif event.msg == "open" then setstate(POS(-2085,11,918),"green") return elseif event.msg == "close" then setstate(POS(-2085,11,918),"red") return end return end if event.type=="int" then if event.msg=="clear_signal" then setstate(POS(-2085,11,918),"red") end return end \ No newline at end of file +if event.type=="digiline" then if event.channel ~= "trainctl" then return end if event.msg == "send" then setstate(POS(-2085,11,918),"green") setstate(POS(-2084,9,915),"on") if atc_id and atc_arrow then atc_send("S0B0WRD1RB5S5") elseif atc_id and atc_arrow == false then atc_send("B0S0WRS5") end interrupt(10,"clear_signal") return elseif event.msg == "open" then setstate(POS(-2085,11,918),"green") setstate(POS(-2084,9,915),"on") return elseif event.msg == "close" then setstate(POS(-2085,11,918),"red") setstate(POS(-2084,9,915),"off") return end return end if event.type=="int" then if event.msg=="clear_signal" then setstate(POS(-2085,11,918),"red") end return end \ No newline at end of file diff --git a/durt/nodes/(-2213,8,898).lua b/durt/nodes/(-2213,8,898).lua new file mode 100644 index 0000000..3d93bd0 --- /dev/null +++ b/durt/nodes/(-2213,8,898).lua @@ -0,0 +1 @@ +if event.type=="digiline" then if event.channel ~= "trainctl" then return end if event.msg == "send" then if atc_id and atc_arrow then atc_send("S0WRS4") elseif atc_id and atc_arrow == false then atc_send("S4") end end end \ No newline at end of file diff --git a/durt/nodes/(-2732,11,891).lua b/durt/nodes/(-2732,11,891).lua new file mode 100644 index 0000000..e69de29 diff --git a/durt/nodes/(-2734,11,891).lua b/durt/nodes/(-2734,11,891).lua new file mode 100644 index 0000000..e69de29 diff --git a/durt/nodes/(-3525,8,-2281).lua b/durt/nodes/(-3525,8,-2281).lua index 6bb5ea1..cb3c02c 100644 --- a/durt/nodes/(-3525,8,-2281).lua +++ b/durt/nodes/(-3525,8,-2281).lua @@ -1,3 +1,8 @@ if event.train then - if not atc_arrow then atc_send("S1B1") end + if not atc_arrow then + atc_send("S1B1") + set_autocouple() + else + digiline_send("lcd",atc_id) + end end \ No newline at end of file diff --git a/durt/nodes/(-3544,8,-2277).lua b/durt/nodes/(-3544,8,-2277).lua index e6d9f27..37c1019 100644 --- a/durt/nodes/(-3544,8,-2277).lua +++ b/durt/nodes/(-3544,8,-2277).lua @@ -1 +1 @@ - --East End of Loading Road local siding_id = "TreeFarm" local control_interface = POS(-3553,18,-2261) local loading_sig = POS(-3539,9,-2279) local exit_route = "Exit to Mainline" local accelerator_loop_diverge_sig = POS(-3602,9,-2282) if event.type=="ext_int" then if not atc_id then interrupt_pos(control_interface,"No Train at Signal") return elseif atc_speed ~= 0 then interrupt_pos(control_interface,"Train Still Moving") return end if event.message == "shuffle" then if can_set_route(loading_sig,"Loop Around") then set_route(loading_sig,"Loop Around") set_route(accelerator_loop_diverge_sig,"Loading Road") atc_send("S8") else interrupt_pos(control_interface,"Unable to set route") end elseif event.message == "depart" then atc_set_text_outside("Preparing to Depart") interrupt_pos(control_interface,"Preparing to Depart") interrupt(5,"depart") else interrupt_pos(control_interface,"Unknown Command:||"..tostring(event.msg)) end end if event.type=="int" then if event.message == "depart" then set_route(loading_sig,"Exit to Mainline") atc_send("SM") atc_set_text_inside("-- Manifest --\nCargo: Logs and Leaves\nOrigin: Auto Logging Plantation") atc_set_text_outside("") end end \ No newline at end of file +---------------------------------------------- --East End of Loading Road local siding_id = "TreeFarm" local control_interface = POS(-3553,18,-2261) local loading_sig = POS(-3539,9,-2279) local exit_route = "Exit to Mainline" local accelerator_loop_diverge_sig = POS(-3602,9,-2282) if event.type=="ext_int" then if not atc_id then interrupt_pos(control_interface,"No Train at Signal") return elseif atc_speed ~= 0 then interrupt_pos(control_interface,"Train Still Moving") return end if event.message == "shuffle" then if can_set_route(loading_sig,"Loop Around") then set_route(loading_sig,"Loop Around") set_route(accelerator_loop_diverge_sig,"Loading Road (Left)") atc_send("S8") else interrupt_pos(control_interface,"Unable to set route") end elseif event.message == "depart" then atc_set_text_outside("Preparing to Depart") interrupt_pos(control_interface,"Preparing to Depart") interrupt_safe(5,"depart") else interrupt_pos(control_interface,"Unknown Command:||"..tostring(event.msg)) end end if event.type=="int" then if event.message == "depart" then set_route(loading_sig,"Exit to Mainline") atc_send("SM") atc_set_text_inside("-- Manifest --\nCargo: Logs and Leaves\nOrigin: Auto Logging Plantation") atc_set_text_outside("Maverick2797 Organic Diamonds\nFrom Tree to Shiny!") unset_autocouple() end end \ No newline at end of file diff --git a/durt/nodes/(-3552,16,-2275).lua b/durt/nodes/(-3552,16,-2275).lua new file mode 100644 index 0000000..4225d33 --- /dev/null +++ b/durt/nodes/(-3552,16,-2275).lua @@ -0,0 +1 @@ +digiline_send("","Active: "..tostring(S.TreeFarm.yard_active)) \ No newline at end of file diff --git a/durt/nodes/(-3588,8,-2277).lua b/durt/nodes/(-3588,8,-2277).lua index 0cb4557..c0fbf23 100644 --- a/durt/nodes/(-3588,8,-2277).lua +++ b/durt/nodes/(-3588,8,-2277).lua @@ -1 +1,2 @@ - --West End of Loading Road local siding_id = "TreeFarm" local control_interface = POS(-3553,18,-2261) local hs_sig = POS(-3594,9,-2277) local hs_route = "Shunt Around Via Loop" if not S[siding_id] then S[siding_id] = {} end if not atc_arrow then atc_send("B1") end if not S[siding_id].yard_active then if atc_arrow then S[siding_id].yard_active = true S[siding_id].info = { ['rc'] = get_rc() or "", ['line'] = get_line() or "" } -- set_rc("AROUND") split_off_locomotive("B0WR") set_autocouple() set_route(hs_sig,hs_route) atc_send("S4") end else if atc_arrow then -- train has rejoined atc_send("B0WD2RS1") -- reverse and load train set_rc(S[siding_id].info.rc) set_line(S[siding_id].info.line) unset_autocouple() interrupt_pos(control_interface,"Train Shunted||Now Loading") S[siding_id].info.rc = nil S[siding_id].info.line = nil S[siding_id].yard_active = nil end end \ No newline at end of file +------------------------------------------------------------------ --West End of Loading Road local siding_id = "TreeFarm" local control_interface = POS(-3553,18,-2261) local hs_sig = POS(-3594,9,-2277) local hs_route = "Shunt Around Via Loop" if not S[siding_id] then S[siding_id] = {} end if not atc_arrow then atc_send("B1") end if not S[siding_id].yard_active then if atc_arrow then S[siding_id].yard_active = true S[siding_id].info = { ['rc'] = get_rc() or "", ['line'] = get_line() or "" } -- set_rc("AROUND") + step_fc() split_off_locomotive("B0WR") set_route(hs_sig,hs_route) atc_send("S4") end else if atc_arrow then -- train has rejoined atc_send("B0WD2RS1") -- reverse and load train set_rc(S[siding_id].info.rc) set_line(S[siding_id].info.line) unset_autocouple() interrupt_pos(control_interface,"Train Shunted||Now Loading") S[siding_id].info.rc = nil S[siding_id].info.line = nil S[siding_id].yard_active = nil end end \ No newline at end of file diff --git a/durt/nodes/(-3761,12,-3554).lua b/durt/nodes/(-3761,12,-3554).lua new file mode 100644 index 0000000..118b1c4 --- /dev/null +++ b/durt/nodes/(-3761,12,-3554).lua @@ -0,0 +1,2 @@ +-- +F.M27_tracking("EV_S<-->Sinensis") \ No newline at end of file diff --git a/durt/nodes/(-585,26,2478).lua b/durt/nodes/(-585,26,2478).lua index 23d349b..f79b2c9 100644 --- a/durt/nodes/(-585,26,2478).lua +++ b/durt/nodes/(-585,26,2478).lua @@ -1 +1 @@ ---arrow points west towards working HS local lane = 4 if S.yard_active == true then if atc_arrow then set_route("CANNERY_W"..lane, "HEADSHUNT") -- turnouts should already be set by the train returning from HS local plen = train_length() local rc = split_at_fc("B0") local trc = "CAN_"..rc if plen == train_length() and (rc == "" or S.rc:match(trc)) then S.exiting = true end if rc and rc ~= "" then set_rc("CAN_"..rc) else set_rc(S.rc) S.exiting = true end end end \ No newline at end of file +--arrow points west towards working HS local lane = 4 if S.yard_active == true then if atc_arrow then set_route("CANNERY_W"..lane, "HEADSHUNT") -- turnouts should already be set by the train returning from HS local plen = train_length() local rc = split_at_fc("B0",3) local trc = "CAN_"..rc if plen == train_length() and (rc == "" or S.rc:match(trc)) then S.exiting = true end if rc and rc ~= "" then set_rc("CAN_"..rc) else set_rc(S.rc) S.exiting = true end end end \ No newline at end of file diff --git a/durt/nodes/(-716,3,1873).lua b/durt/nodes/(-716,3,1873).lua new file mode 100644 index 0000000..fad9270 --- /dev/null +++ b/durt/nodes/(-716,3,1873).lua @@ -0,0 +1,3 @@ +__approach_callback_mode = 1 if event.approach and not event.has_entered then atc_set_ars_disable(true) atc_set_lzb_tsr(1) end + +if event.train and atc_arrow then atc_send("S1") end \ No newline at end of file diff --git a/durt/nodes/(-716,3,1892).lua b/durt/nodes/(-716,3,1892).lua new file mode 100644 index 0000000..bb8cdaf --- /dev/null +++ b/durt/nodes/(-716,3,1892).lua @@ -0,0 +1 @@ +__approach_callback_mode = 1 if event.approach and not event.has_entered then atc_set_ars_disable(true) atc_set_lzb_tsr(1) end if event.train and atc_arrow then atc_set_ars_disable(false) atc_send("SM") end \ No newline at end of file diff --git a/durt/nodes/(-733,3,1854).lua b/durt/nodes/(-733,3,1854).lua new file mode 100644 index 0000000..fad9270 --- /dev/null +++ b/durt/nodes/(-733,3,1854).lua @@ -0,0 +1,3 @@ +__approach_callback_mode = 1 if event.approach and not event.has_entered then atc_set_ars_disable(true) atc_set_lzb_tsr(1) end + +if event.train and atc_arrow then atc_send("S1") end \ No newline at end of file diff --git a/durt/nodes/(-734,3,1828).lua b/durt/nodes/(-734,3,1828).lua new file mode 100644 index 0000000..bb8cdaf --- /dev/null +++ b/durt/nodes/(-734,3,1828).lua @@ -0,0 +1 @@ +__approach_callback_mode = 1 if event.approach and not event.has_entered then atc_set_ars_disable(true) atc_set_lzb_tsr(1) end if event.train and atc_arrow then atc_set_ars_disable(false) atc_send("SM") end \ No newline at end of file diff --git a/durt/nodes/(1817,11,9226).lua b/durt/nodes/(1817,11,9226).lua new file mode 100644 index 0000000..a749beb --- /dev/null +++ b/durt/nodes/(1817,11,9226).lua @@ -0,0 +1 @@ +F.yard_road_count("WOA","WOA_ass_W","WOA_ass_W") \ No newline at end of file diff --git a/durt/nodes/(1819,11,9227).lua b/durt/nodes/(1819,11,9227).lua new file mode 100644 index 0000000..43153e0 --- /dev/null +++ b/durt/nodes/(1819,11,9227).lua @@ -0,0 +1 @@ +F.yard_road_count("WOA","WOA_ass_C","WOA_ass_C") \ No newline at end of file diff --git a/durt/nodes/(1819,11,9233).lua b/durt/nodes/(1819,11,9233).lua new file mode 100644 index 0000000..c833ab1 --- /dev/null +++ b/durt/nodes/(1819,11,9233).lua @@ -0,0 +1 @@ +F.yard_road_count("WOA","WOA_ass_E","WOA_ass_E") \ No newline at end of file diff --git a/durt/nodes/(1852,8,9034).lua b/durt/nodes/(1852,8,9034).lua new file mode 100644 index 0000000..7489acc --- /dev/null +++ b/durt/nodes/(1852,8,9034).lua @@ -0,0 +1 @@ +-- \ No newline at end of file diff --git a/durt/nodes/(1854,11,9164).lua b/durt/nodes/(1854,11,9164).lua new file mode 100644 index 0000000..a749beb --- /dev/null +++ b/durt/nodes/(1854,11,9164).lua @@ -0,0 +1 @@ +F.yard_road_count("WOA","WOA_ass_W","WOA_ass_W") \ No newline at end of file diff --git a/durt/nodes/(1856,11,9165).lua b/durt/nodes/(1856,11,9165).lua new file mode 100644 index 0000000..43153e0 --- /dev/null +++ b/durt/nodes/(1856,11,9165).lua @@ -0,0 +1 @@ +F.yard_road_count("WOA","WOA_ass_C","WOA_ass_C") \ No newline at end of file diff --git a/durt/nodes/(1864,11,9161).lua b/durt/nodes/(1864,11,9161).lua new file mode 100644 index 0000000..c833ab1 --- /dev/null +++ b/durt/nodes/(1864,11,9161).lua @@ -0,0 +1 @@ +F.yard_road_count("WOA","WOA_ass_E","WOA_ass_E") \ No newline at end of file diff --git a/durt/nodes/(1865,17,9141).lua b/durt/nodes/(1865,17,9141).lua new file mode 100644 index 0000000..ab7f545 --- /dev/null +++ b/durt/nodes/(1865,17,9141).lua @@ -0,0 +1 @@ +turnouts = { {1870,11,9122},-- Southern headshunt/Goods Shed {1863,11,9122},--Southern Roads {1857,11,9122}, {1851,11,9122}, {1845,11,9122}, {1782,11,9222},--NW Roads {1782,11,9216}, {1782,11,9210}, {1782,11,9204}, {1868,11,9157}, --Eastern Assembly Roads {1860,11,9161}, {1817,11,9237}, {1817,11,9231}, {1822,11,9251}, --Northern Wye {1817,11,9238}, {1806,11,9243}, } routes = { -- max# of routes = 32 (1-31 + R0) --southern headshunt {['matrix']={"1st"}, ['name']="Goods Shed Headshunt"}, --1 {['matrix']={"1cr"}, ['name']="West Assembly Yard"}, --2 --southern road access {['matrix']={"2cr"}, ['name']="East S1"}, --3 {['matrix']={"2st","3cr"}, ['name']="East S2"}, --4 {['matrix']={"2st","3st","4cr"}, ['name']="East S3"}, --5 {['matrix']={"2st","3st","4st","5cr"}, ['name']="East S4"}, --6 {['matrix']={"2st","3st","4st","5st"}, ['name']="East S5"}, --7 --NW road access {['matrix']={"6cr"}, ['name']="East N1"}, --8 {['matrix']={"6st","7cr"}, ['name']="East N2"}, --9 {['matrix']={"6st","7st","8cr"}, ['name']="East N3"}, --10 {['matrix']={"6st","7st","8st","9cr"}, ['name']="East N4"}, --11 {['matrix']={"6st","7st","8st","9st"}, ['name']="East N5"}, --12 --Eastern Assembly Roads {['matrix']={"10st","12cr"}, ['name']="Assembly East"}, --13 {['matrix']={"10cr","11cr","12st","13cr"}, ['name']="Assembly Central"}, --14 {['matrix']={"10cr","11st","12st","13st"}, ['name']="Assembly West"}, --15 --Norther Wye {['matrix']={"15st","14cr"}, ['name']="Assembly<->Station"}, --16 {['matrix']={"15cr","16cr"}, ['name']="Yard Loopback"}, --17 {['matrix']={"14st","16st"}, ['name']="Bypass Yard"}, --18 --testing routes {['matrix']={"1cr","2cr","3cr","4cr","5cr"}, ['name']="[TEST]Southern Cr"}, --19 {['matrix']={"1st","2st","3st","4st","5st"}, ['name']="[TEST]Southern St"}, --20 {['matrix']={"6st","7st","8st","9st"}, ['name']="[TEST]Northern St"}, --21 {['matrix']={"6cr","7cr","8cr","9cr"}, ['name']="[TEST]Northern Cr"}, --22 } local display = "tl1" local debug_screen = "tl2" function tableLength(T) local count = 0 for _ in pairs(T) do count = count + 1 end return count end if event.type=="digiline" then if event.channel=="track_control" then local r = event.msg if r > tableLength(routes) then digiline_send(display,"Input ["..r.."] exceeds #routes||"..tableLength(routes)) -- digiline_send(debug_screen,"Input ["..r.."] exceeds #routes ("..tableLength(routes)..")") return elseif r == 0 then digiline_send(display,"Input 0 is not defined") -- digiline_send(debug_screen,"Input 0 is not defined") return end route = routes[r] -- a = "" for _,v in pairs(route.matrix) do local tid = tonumber(v:match("%d+")) local tpos = turnouts[tid] local turnout = {} turnout.x = tpos[1] turnout.y = tpos[2] turnout.z = tpos[3] local cmd = v:match("%a+") -- a = a..string.format("%s %d,%d,%d\n",cmd,turnout.x,turnout.y,turnout.z) setstate(turnout,cmd) end local verbose = table.concat(route.matrix," ") digiline_send(display,"Route "..r.." set||"..verbose.."||"..route.name) -- digiline_send(debug_screen,a) return end if event.channel=="input" then --show debug info if event.msg=="rwt_get" then digiline_send("rwt_get",rwt.now()) elseif event.msg=="debug" then digiline_send(debug_screen,"#turnouts: "..tableLength(turnouts).."\n#routes: "..tableLength(routes)) elseif event.msg=="occupancy_refresh" then local m = "" for k,v in pairs(S.yards.WOA) do m = m..k..": "..v.car_count.."||" end digiline_send(debug_screen,m) end end end \ No newline at end of file diff --git a/durt/nodes/(1866,11,9122).lua b/durt/nodes/(1866,11,9122).lua new file mode 100644 index 0000000..577ba71 --- /dev/null +++ b/durt/nodes/(1866,11,9122).lua @@ -0,0 +1 @@ +__approach_callback_mode = 2 if event.approach and not event.has_entered then atc_set_lzb_tsr(1) end \ No newline at end of file diff --git a/durt/nodes/(1874,11,9122).lua b/durt/nodes/(1874,11,9122).lua new file mode 100644 index 0000000..fdee831 --- /dev/null +++ b/durt/nodes/(1874,11,9122).lua @@ -0,0 +1 @@ +F.yard_road_count("WOA","hs","WOA_hs") \ No newline at end of file diff --git a/durt/nodes/(1904,7,9133).lua b/durt/nodes/(1904,7,9133).lua new file mode 100644 index 0000000..22bd87c --- /dev/null +++ b/durt/nodes/(1904,7,9133).lua @@ -0,0 +1 @@ +local yard_id = "WOA" __approach_callback_mode = 1 if event.approach and not event.has_entered then atc_set_ars_disable(true) atc_set_lzb_tsr(1) end if event.train and atc_arrow then atc_send("S1") S.yards[yard_id].last_pass2 = S.yards[yard_id].last_pass1 or rwt.now() S.yards[yard_id].last_pass1 = rwt.now() S.yards[yard_id].last_id = atc_id end if event.train then local init = false if not S.WOA_stats then S.WOA_stats = true init = true end F.stat("WOA_mine",init) end \ No newline at end of file diff --git a/durt/nodes/(1907,9,9129).lua b/durt/nodes/(1907,9,9129).lua new file mode 100644 index 0000000..6e01750 --- /dev/null +++ b/durt/nodes/(1907,9,9129).lua @@ -0,0 +1,2 @@ +local yard_id = "WOA" if event.schedule then local now = rwt.now() local last = S.yards[yard_id].last_pass1 local dtime = rwt.diff(last,now) local rtt = rwt.diff(S.yards[yard_id].last_pass2,last) digiline_send("lcd",string.format("Now: %s |Last Pass: %s |ID: %s Delta: %s |TBT: %s ",rwt.to_string(now),rwt.to_string(last),S.yards.WOA.last_id,rwt.to_string(dtime),rwt.to_string(rtt))) schedule(rwt.next_rpt(rwt.now(), "0;05", 0)) end if event.punch then schedule(rwt.next_rpt(rwt.now(), "0;05", 0)) + if S.WOA_stats == true then S.WOA_stats = false end end \ No newline at end of file diff --git a/durt/nodes/(1909,8,9115).lua b/durt/nodes/(1909,8,9115).lua new file mode 100644 index 0000000..224bafc --- /dev/null +++ b/durt/nodes/(1909,8,9115).lua @@ -0,0 +1,5 @@ +do return end + + + +local foundry_track = POS(-1962,13,-1709) local warmoneaye_track = POS(1918,7,9099) if event.ext_int then if type(event.msg) == "string" then digiline_send("lcd",event.msg) end if type(event.msg) == "table" then local m = event.msg local location = m.location local message = m.msg digiline_send(location,message) return end end if event.digiline then if event.channel=="send" then -- interrupt_pos(foundry_track,"send") interrupt_pos(warmoneaye_track,"send") end end if event.punch then digiline_send("Foundry","test") digiline_send("Warmoneaye","test") end \ No newline at end of file diff --git a/durt/nodes/(1914,7,9096).lua b/durt/nodes/(1914,7,9096).lua new file mode 100644 index 0000000..bb8cdaf --- /dev/null +++ b/durt/nodes/(1914,7,9096).lua @@ -0,0 +1 @@ +__approach_callback_mode = 1 if event.approach and not event.has_entered then atc_set_ars_disable(true) atc_set_lzb_tsr(1) end if event.train and atc_arrow then atc_set_ars_disable(false) atc_send("SM") end \ No newline at end of file diff --git a/durt/nodes/(1918,7,9099).lua b/durt/nodes/(1918,7,9099).lua new file mode 100644 index 0000000..3df43db --- /dev/null +++ b/durt/nodes/(1918,7,9099).lua @@ -0,0 +1 @@ +local location = "Warmoneaye" local ctl_pan = POS(1919,7,9093) local signal = POS(1919,10,9094) local route = "Exit South" err = interrupt_pos if event.ext_int then if not atc_id then err(ctl_pan,{['location'] = location, ['msg'] = " | No Train"}) end if event.msg == "send" then set_route(signal,route) if atc_arrow then atc_send("SM") else atc_send("S0WRSM") end end end \ No newline at end of file diff --git a/durt/nodes/(1918,7,9147).lua b/durt/nodes/(1918,7,9147).lua new file mode 100644 index 0000000..7489acc --- /dev/null +++ b/durt/nodes/(1918,7,9147).lua @@ -0,0 +1 @@ +-- \ No newline at end of file diff --git a/durt/nodes/(1921,7,9096).lua b/durt/nodes/(1921,7,9096).lua new file mode 100644 index 0000000..32d89d7 --- /dev/null +++ b/durt/nodes/(1921,7,9096).lua @@ -0,0 +1 @@ +if event.digiline then if event.channel ~= "track_control" then return end local err = 0 if not atc_id then err = 1 end if not atc_arrow then err = 1 end if type(event.msg) ~= "table" then err = 1 end if err == 1 then digiline_send("lcd","--Error-- | Check Train") return end local i = event.msg set_rc(i.ars or "") atc_set_text_inside("Destination: "..(i.name or "Unknown").."\nCargo: "..(i.info or "Unknown")) end \ No newline at end of file diff --git a/durt/nodes/(1921,7,9148).lua b/durt/nodes/(1921,7,9148).lua new file mode 100644 index 0000000..7489acc --- /dev/null +++ b/durt/nodes/(1921,7,9148).lua @@ -0,0 +1 @@ +-- \ No newline at end of file diff --git a/durt/nodes/(1928,8,9112).lua b/durt/nodes/(1928,8,9112).lua new file mode 100644 index 0000000..82f90cc --- /dev/null +++ b/durt/nodes/(1928,8,9112).lua @@ -0,0 +1 @@ +-- do return end --if event.punch then schedule(1) end if event.schedule then local t = rwt.now() for k,v in pairs(t) do if v < 10 then t[k] = "0"..v end end time = string.format("Warmoneaye | | Railway Time | %s;%s",tostring(t.m),tostring(t.s)) digiline_send("clock",time) schedule(1) end \ No newline at end of file diff --git a/durt/nodes/(1968,39,8411).lua b/durt/nodes/(1968,39,8411).lua new file mode 100644 index 0000000..1a91da0 --- /dev/null +++ b/durt/nodes/(1968,39,8411).lua @@ -0,0 +1,3 @@ +if atc_arrow == true and get_line() == "DTLS1" then + atc_set_text_outside("DTL S1 -> Banana Place Central") +end \ No newline at end of file diff --git a/durt/nodes/(431,-11,-256).lua b/durt/nodes/(431,-11,-256).lua new file mode 100644 index 0000000..8f8784e --- /dev/null +++ b/durt/nodes/(431,-11,-256).lua @@ -0,0 +1,9 @@ +if atc_arrow == true then + local rc = get_rc() + if rc:find("bh_ewb_unload") then + setstate("s_bh_ewb", "st") + end + if rc:find("bh_ewb_load") then + setstate("s_bh_ewb", "cr") + end +end \ No newline at end of file diff --git a/durt/nodes/(434,-4,-200).lua b/durt/nodes/(434,-4,-200).lua new file mode 100644 index 0000000..b072d04 --- /dev/null +++ b/durt/nodes/(434,-4,-200).lua @@ -0,0 +1,7 @@ +if event.type == "train" then + rc = get_rc() + if rc:find("d23a_leave") ~= nil then + rc = rc:gsub("d23a_leave", "d23_unload") + end + set_rc(rc) +end \ No newline at end of file diff --git a/durt/nodes/(442,-4,-198).lua b/durt/nodes/(442,-4,-198).lua new file mode 100644 index 0000000..028a50e --- /dev/null +++ b/durt/nodes/(442,-4,-198).lua @@ -0,0 +1,9 @@ +if event.type == "train" then + local rc = get_rc() + if rc:find("d23a_unload") ~= nil then + rc = rc:gsub("d23a_unload", "d23a_load") + elseif rc:find("d23a_load") ~= nil then + rc = rc:gsub("d23a_load", "d23a_leave") + end + set_rc(rc) +end \ No newline at end of file diff --git a/durt/nodes/(446,-4,-201).lua b/durt/nodes/(446,-4,-201).lua new file mode 100644 index 0000000..028a50e --- /dev/null +++ b/durt/nodes/(446,-4,-201).lua @@ -0,0 +1,9 @@ +if event.type == "train" then + local rc = get_rc() + if rc:find("d23a_unload") ~= nil then + rc = rc:gsub("d23a_unload", "d23a_load") + elseif rc:find("d23a_load") ~= nil then + rc = rc:gsub("d23a_load", "d23a_leave") + end + set_rc(rc) +end \ No newline at end of file diff --git a/durt/nodes/(771,25,8503).lua b/durt/nodes/(771,25,8503).lua new file mode 100644 index 0000000..58252f0 --- /dev/null +++ b/durt/nodes/(771,25,8503).lua @@ -0,0 +1,3 @@ +if atc_arrow == true and get_line() == "DTLS1" then + atc_set_text_outside("DTL S1 -> Azena Transirejo") +end \ No newline at end of file diff --git a/ers/init_code.lua b/ers/init_code.lua new file mode 100644 index 0000000..f0a5c4d --- /dev/null +++ b/ers/init_code.lua @@ -0,0 +1,91 @@ +-- environment_ers.lua +F.debug = true + +F.isempty = function (s) + return s == nil or s == '' +end + +F.print = function (str) + if F.debug then + print("PrntMsg: ".. (str or "nil") ) + end +end + +S.train_duration = {} +F.train_duration = function(type) + if not atc_id then return end + local now = os.date("%H:%M:%S") + if F.isempty(type) then + type = "start" + end + if not S.train_duration[atc_id] then + S.train_duration[atc_id] = { ["start"] = "", ["end"] = "" } + end + if type == "start" then + S.train_duration[atc_id]["end"] = "Nil" + end + S.train_duration[atc_id][type] = now +end + +F.train_info = function (passive_name, show_print) + local timestart = "" + local timeend = "" + local time_message = "" + if F.isempty(passive_name) or passive_name == "RESETALL" then + msg_atc_id = "No Train" + if passive_name == "RESETALL" then + S.train_duration = {} + end + else + timestart = S.train_duration[atc_id]["start"] + timeend = S.train_duration[atc_id]["end"] + msg_atc_id = atc_id + end + local lcd_message = "" .. + msg_atc_id .. + "" + + if not F.isempty(timestart) and not F.isempty(timeend) then + time_message = "Time: | " .. timestart .. " to " .. timeend + elseif not F.isempty(timestart) and F.isempty(timeend) then + time_message = "Start Time: | " .. timestart + else + time_message = "RegTime: | " .. os.date("%H:%M:%S") + end + + digiline_send("lcd", lcd_message) + digiline_send("time", time_message) + local message = lcd_message .. " | " .. time_message + + if show_print == true then + F.print(message) + end +end + +F.does_train_have_rc = function(wanted_rc) + local rc = get_rc() or "" + if rc:match(wanted_rc) then + return true + else + return false + end +end + +F.send_route = function(passive_name, route, show_print) + if can_set_route(passive_name, route) then + set_route(passive_name, route) + if show_print == true then + F.print(passive_name .. " has been set to " .. route) + end + return true + else + if show_print == true then + F.print(route .. " cannot be set for " .. passive_name .. ". Try another") + end + return false + end +end + +if event.type == "init" then + F.print("Initialized") +end \ No newline at end of file diff --git a/ers/nodes/(1655,1,1261).lua b/ers/nodes/(1655,1,1261).lua new file mode 100644 index 0000000..2d9ef7a --- /dev/null +++ b/ers/nodes/(1655,1,1261).lua @@ -0,0 +1,30 @@ +-- luaatctrack_main_depot_01.lua +local show_print = false +if event.train then + if atc_arrow then + local passive_name = "ErsDepotTurnaround" + local track_route = "" + local can_do_route = false + F.train_duration("start") + F.train_info(passive_name, show_print) + + if F.does_train_have_rc("ERSTAZIDEPOTUNLOAD") then + track_route = "01 UNLOADING TRACK" + F.send_route(passive_name, track_route, show_print) + elseif F.does_train_have_rc("ERSTAZITST") then + track_route = "02 LOADING TRACK" + F.send_route(passive_name, track_route, show_print) + else + track_route = "03 EXTRA" + can_do_route = F.send_route(passive_name, track_route, show_print) + if can_do_route == false then + track_route = "04 EXTRA" + F.send_route(passive_name, track_route, show_print) + end + end + else + local passive_name = "ErsDepotTurnaround" + F.train_duration("end") + F.train_info(passive_name, show_print) + end +end \ No newline at end of file diff --git a/ers/nodes/(1655,1,1264).lua b/ers/nodes/(1655,1,1264).lua new file mode 100644 index 0000000..0cb6ef7 --- /dev/null +++ b/ers/nodes/(1655,1,1264).lua @@ -0,0 +1,6 @@ +-- luaoperatingpanel_depot_01.lua +local show_print = false +if event.type == "punch" then + F.train_info("RESETALL", show_print) + return +end \ No newline at end of file diff --git a/ers/nodes/(3159,74,2331).lua b/ers/nodes/(3159,74,2331).lua new file mode 100644 index 0000000..e69de29 diff --git a/il_timetable/init_code.lua b/il_timetable/init_code.lua index 313075b..e44819e 100644 --- a/il_timetable/init_code.lua +++ b/il_timetable/init_code.lua @@ -37,4 +37,455 @@ end function F.timedisplay() digiline_send("time", "Time: | "..rwt.to_string(rwt.now(),true).." | "..os.date("%H:%M:%S")) schedule(rwt.next_rpt(rwt.now(),5,0), "") -end \ No newline at end of file +end + +-- Stat counter and timetaking utilities +-- Stat from subway +F.stat=function(line, init) +--statistics +-- init +if init then +reftrain = atc_id +a_tbt = 30 +a_tbtmax = 30 +a_rtt = 500 +a_not = 0 +c_not = 0 +c_tbtmax = 0 +time_lt = os.time() +time_rt=os.time() +end +if not a_tbtmax then a_tbtmax = 30 end +if not c_tbtmax then c_tbtmax = 0 end +--real code +if event.train then +local time = os.time() +c_not = c_not + 1 +a_tbt = (a_tbt + (time - time_lt)) / 2 +c_tbtmax = math.max(c_tbtmax, (time - time_lt)) +if atc_id == reftrain then + a_rtt = (a_rtt*0.2 + (time - time_rt)*0.8) + a_not = c_not + c_not = 0 + a_tbtmax = (a_tbtmax + c_tbtmax) / 2 + c_tbtmax = 0 +end + digiline_send("stats", "Stat: "..line.. + " NoT:"..a_not.."("..c_not..")".. + " TbT:"..math.floor(a_tbt).."("..(time-time_lt)..")".. + " Tmx:"..math.floor(a_tbtmax).."("..c_tbtmax..")".. + " R:"..math.floor(a_rtt).."("..(time - time_rt)..")" + ) +time_lt = time +if atc_id == reftrain then + time_rt = time +end +end +end + +S.timetake = {} +function F.timetake_start(ttname) + if not atc_id then return end + local nouw = rwt.to_secs(rwt.now()) + if not S.timetake[ttname] then + S.timetake[ttname] = {} + end + S.timetake[ttname][atc_id] = nouw +end + +--L100 +function F.timetake_end(ttname) + if not atc_id then return end + if not S.timetake[ttname] or not S.timetake[ttname][atc_id] then + digiline_send("timetake", "No start time for "..atc_id) + return + end + local first = S.timetake[ttname][atc_id] + local nouw = rwt.to_secs(rwt.now()) + local tdiff = nouw - first + local cavg = S.timetake[ttname].avg + local cmax = S.timetake[ttname].max + local cmin = S.timetake[ttname].min + if cavg and cmax and cmin then + S.timetake[ttname].avg = tdiff*0.1 + cavg*0.9 + S.timetake[ttname].min = math.min(tdiff, cmin) + S.timetake[ttname].max = math.max(tdiff, cmax) + else + S.timetake[ttname].avg = tdiff + S.timetake[ttname].min = tdiff + S.timetake[ttname].max = tdiff + end + digiline_send("timetake", ttname.. + " this:"..tdiff.. + " min:"..math.floor(S.timetake[ttname].min).. + " avg:"..math.floor(S.timetake[ttname].avg).. + " max:"..math.floor(S.timetake[ttname].max) + ) + +end + +--== Timetable prototype (TTP) === +--[[ table structures: +F.ttp - static timetable data - see below +S.ttp[tt_name] = { - dynamic tt data + recording_train = + travel_times = { + =