summaryrefslogtreecommitdiff
path: root/far
diff options
context:
space:
mode:
Diffstat (limited to 'far')
-rw-r--r--far/init_code.lua115
-rw-r--r--far/nodes/(1753,8,1570).lua2
-rw-r--r--far/nodes/(1771,10,1563).lua2
-rw-r--r--far/nodes/(30856,15,1814).lua2
-rw-r--r--far/nodes/(30863,15,1807).lua2
-rw-r--r--far/nodes/(30870,15,1800).lua2
-rw-r--r--far/nodes/(5323,32,2321).lua3
-rw-r--r--far/nodes/(5326,32,2311).lua3
-rw-r--r--far/nodes/(5409,33,2336).lua3
-rw-r--r--far/nodes/(5409,33,2339).lua3
-rw-r--r--far/nodes/(5434,33,2329).lua3
-rw-r--r--far/nodes/(5434,33,2332).lua3
-rw-r--r--far/nodes/(5856,21,2314).lua3
-rw-r--r--far/nodes/(5856,21,2315).lua3
14 files changed, 86 insertions, 63 deletions
diff --git a/far/init_code.lua b/far/init_code.lua
index 0ad2749..49b0be6 100644
--- a/far/init_code.lua
+++ b/far/init_code.lua
@@ -1,15 +1,42 @@
-- environment_far.lua
+--[[
+local STOP_TIME = 40
+local STOPCMD="B0WO"
+local DEPCMD="A1OCD1SM"
+local RDEPCMD="RA1OCD1SM"
+local DYNAMIC_THR = 10
+local DYNAMIC_EN = false
+]]
+
if S.trains == nil then S.trains = {} end
if S.d == nil then S.d = {} end
if S.datetime == nil then S.datetime = "" end
if S.stop_display == nil then S.stop_display = false end
if S.show_farpass_only == nil then S.show_farpass_only = false end
+if S.timetake == nil then S.timetake = {} end
+if S.ttp == nil then S.ttp = {} end
+if S.ttt == nil then S.ttt = {} end
+
+F.ttp={
+ FAR_E = {
+ outside_text = "[FAR] Fareast End\nvia Halfway, Bayonne, Fucking",
+ inside_line_desc = "FAR to Fareast End",
+ stn_display = "FAR Fareast End",
+ },
+ FAR_W = {
+ outside_text = "[FAR] Salt Factory\nvia Fucking, Bayonne, Halfway",
+ inside_line_desc = "FAR to Salt Factory",
+ stn_display = "FAR Salt Factory",
+ },
+}
+-- S.ttp["FAR_E"].force_tt_reset = true
F.print = function (str) if F.debug then print("".. (str or "nil") ) end end
F.isempty = function (s) return s == nil or s == "" end
F.get_rc_safe = function() return get_rc() or "" end
F.get_line_safe = function() return get_line() or "" end
F.get_train_length_safe = function() return train_length() or 0 end
+
F.avg = function(t)
local sum = 0
local count = 0
@@ -26,6 +53,12 @@ if event.init then
F.debug = true
F.printAllTrainsInfo = true
F.max_displays = 15
+ F.STOP_TIME = 40
+ F.STOPCMD="B0WO"
+ F.DEPCMD="A1OCD1SM"
+ F.RDEPCMD="RA1OCD1SM"
+ F.DYNAMIC_THR = 10
+ F.DYNAMIC_EN = false
F.print("Initialized")
end
@@ -229,7 +262,7 @@ function F.stop_sd(st_name, doors, departcommand, minstoptime, d_int, d_off)
local timenow = os.time()
local timerdy = timenow + minstoptime
local wait = d_int - ((timerdy-d_off) % d_int)
- local waitcorr = math.floor(wait*0.66)
+ local waitcorr = math.floor(wait*0.66)
digiline_send("monitor", "Departure scheduled for: | "..os.date("%H:%M:%S", timenow+wait))
atc_send("B0 W O"..doors.." D"..waitcorr.." OCD1"..departcommand)
else
@@ -264,7 +297,7 @@ end
-- Stat from subway
F.stat=function(line, init)
-- statistics
- -- init
+
if init then
reftrain = atc_id
a_tbt = 30
@@ -278,7 +311,7 @@ F.stat=function(line, init)
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
@@ -304,7 +337,6 @@ F.stat=function(line, init)
end
end
-S.timetake = {}
function F.timetake_start(ttname)
if not atc_id then return end
local nouw = rwt.to_secs(rwt.now())
@@ -314,7 +346,6 @@ function F.timetake_start(ttname)
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
@@ -366,28 +397,6 @@ S.ttt[train_id] = { - trains
}
]]
-local STOP_TIME = 40
-local STOPCMD="B0WO"
-local DEPCMD="A1OCD1SM"
-local RDEPCMD="RA1OCD1SM"
-local DYNAMIC_THR = 10
-local DYNAMIC_EN = false
-
-if not S.ttp then S.ttp = {} end
-if not S.ttt then S.ttt = {} end
-F.ttp={
- FAR_E = {
- outside_text = "[FAR] Fareast End\nvia Halfway, Bayonne, Fucking",
- inside_line_desc = "FAR to Fareast End",
- stn_display = "FAR Fareast End",
- },
- FAR_W = {
- outside_text = "[FAR] Salt Factory\nvia Fucking, Bayonne, Halfway",
- inside_line_desc = "FAR to Salt Factory",
- stn_display = "FAR Salt Factory",
- },
-}
-
--[[
Timetable entry point. The train finalizes its last timetable and
registers itself on the given timetable instance. It departs at the next time slot
@@ -395,7 +404,7 @@ registers itself on the given timetable instance. It departs at the next time sl
F.ttp_begin({
stn = "Warmoneaye", -- station name
tt = "CFE_S", -- timetable ID
- depint = "05;00", --departure slot interval
+ depint = "12;00", --departure slot interval
depoff = "00;00", --departure slot offset
doorside = "L",
reverse = true,
@@ -407,8 +416,8 @@ F.ttp_begin({
F.ttp_begin({
stn = "Salt Factory", -- station name
tt = "FAR_E", -- timetable ID
- depint = "05;00", --departure slot interval
- depoff = "03;15", --departure slot offset
+ depint = "12;00", --departure slot interval
+ depoff = "00;00", --departure slot offset
doorside = "L",
reverse = true,
only_lines = {['FAR'] = true},
@@ -442,7 +451,7 @@ function F.ttp_begin(p)
F.save_train(p.pos, p.direction)
end
-- train arrived, planning departure
- atc_send(STOPCMD .. p.doorside)
+ atc_send(F.STOPCMD .. p.doorside)
local time_now = rwt.now()
-- Train might have had another TT before, do the cleanup from ttp_end here.
@@ -484,21 +493,21 @@ function F.ttp_begin(p)
if event.schedule then
-- departure. save actual departure time in tt
if S.ttt[atc_id] then -- failsafe: if entry is deleted externally somehow, train just departs and is not tracked by tt (makes resetting S.ttt possible)
- S.ttt[atc_id].actual_dep = rwt.now()
- local delay = rwt.diff(S.ttt[atc_id].desired_dep, S.ttt[atc_id].actual_dep)
- atc_set_text_inside(F.ttp[p.tt].inside_line_desc .. "\nDelay: " .. rwt.to_string(delay, true))
- S.ttt[atc_id].last_delay = delay
+ S.ttt[atc_id].actual_dep = rwt.now()
+ local delay = rwt.diff(S.ttt[atc_id].desired_dep, S.ttt[atc_id].actual_dep)
+ atc_set_text_inside(F.ttp[p.tt].inside_line_desc .. "\nDelay: " .. rwt.to_string(delay, true))
+ S.ttt[atc_id].last_delay = delay
end
if p.reverse then
- atc_send(RDEPCMD)
+ atc_send(F.RDEPCMD)
else
- atc_send(DEPCMD)
+ atc_send(F.DEPCMD)
end
end
end
--[[
Generic stop on timetable. Any train that has a TT instance registered
-stops here, waits STOP_TIME and continues. Behavior can be altered by options:
+stops here, waits F.STOP_TIME and continues. Behavior can be altered by options:
F.ttp_stop({
stn = "Personhood West", -- station name
doorside = "L",
@@ -506,7 +515,7 @@ F.ttp_stop({
end_of_tt = { TT_ID = true },
-- if present and key is true for a TT identifier, this is the last station on this timetable. Trains will stop recording timetable and be deregistered.
departure = { TT_ID = RWT relative to initial departure },
- -- If present, override desired departure time. Defaults to travel time + STOP_TIME if not provided
+ -- If present, override desired departure time. Defaults to travel time + F.STOP_TIME if not provided
no_disable_ars = nil,
-- if true, does not disable ARS on approach (used for example at INTERCAL)
pos = POS(1,1,1),
@@ -539,7 +548,7 @@ function F.ttp_stop(p)
if event.approach and not event.has_entered then
-- make the train stop
if not p.no_disable_ars then
- atc_set_ars_disable(true)
+ atc_set_ars_disable(true)
end
atc_set_lzb_tsr(2)
atc_set_text_inside("Next stop: "..p.stn)
@@ -548,7 +557,7 @@ function F.ttp_stop(p)
--!-- disaster recovery --!--
-- if event.approach and event.has_entered then
-- print(atc_id,p.stn,"Disaster Recovery...")
--- atc_send(DEPCMD)
+-- atc_send(F.DEPCMD)
-- end
@@ -557,11 +566,10 @@ function F.ttp_stop(p)
F.save_train(p.pos, p.direction)
end
-- train arrived, planning departure
- atc_send(STOPCMD..p.doorside)
+ atc_send(F.STOPCMD..p.doorside)
local time_now = rwt.now()
-- update our location and determine desired and planned departure
---L200
- local next_dep_time = rwt.add(time_now, STOP_TIME)
+ local next_dep_time = rwt.add(time_now, F.STOP_TIME)
trn.location = p.stn
trn.desired_dep = nil
trn.actual_dep = nil
@@ -572,16 +580,16 @@ function F.ttp_stop(p)
p.departure[tt])
elseif tti.travel_times[p.stn] then
trn.desired_dep = rwt.add(trn.initial_dep or 0,
- tti.travel_times[p.stn] + STOP_TIME)
+ tti.travel_times[p.stn] + F.STOP_TIME)
-- dyn travel time
- if DYNAMIC_EN then
+ if F.DYNAMIC_EN then
local ttpd = rwt.diff(next_dep_time, trn.desired_dep)
- if ttpd > DYNAMIC_THR then
- local new_trav = rwt.diff(trn.initial_dep, time_now) + DYNAMIC_THR
+ if ttpd > F.DYNAMIC_THR then
+ local new_trav = rwt.diff(trn.initial_dep, time_now) + F.DYNAMIC_THR
print(atc_id,tt,"arrived at",p.stn,ttpd,"s early, TT",tti.travel_times[p.stn],"->",new_trav)
tti.travel_times[p.stn] = new_trav
trn.desired_dep = rwt.add(trn.initial_dep or 0,
- new_trav + STOP_TIME)
+ new_trav + F.STOP_TIME)
end
end
end
@@ -625,7 +633,7 @@ function F.ttp_stop(p)
atc_set_text_inside(F.ttp[tt].inside_line_desc
.."\nDelay: "..rwt.to_string(delay, true))
S.ttt[atc_id].last_delay = delay
- atc_send(DEPCMD)
+ atc_send(F.DEPCMD)
if p.end_of_tt and p.end_of_tt[tt] then
-- end of timetable. Deregister train
if tti.recording_train == atc_id then
@@ -638,7 +646,6 @@ end
function F.ttp_info_times(tt, starttime)
- --L307
local ttf = F.ttp[tt]
local tti = S.ttp[tt]
local p = {}
@@ -649,14 +656,13 @@ function F.ttp_info_times(tt, starttime)
for i=2,#tti.station_order do
local ap = rwt.add(starttime, tti.travel_times[tti.station_order[i]])
p[#p+1] = ("Ap "..rwt.to_string(ap, true)..
- " Dp "..rwt.to_string(rwt.add(ap, STOP_TIME), false)..
+ " Dp "..rwt.to_string(rwt.add(ap, F.STOP_TIME), false)..
" "..tti.station_order[i])
end
return p
end
function F.ttp_info_trains(tt, starttime)
- --L307
local ttf = F.ttp[tt]
local tti = S.ttp[tt]
local p = {}
@@ -691,7 +697,6 @@ end
show_trainid = false,
}]]
function F.ttp_station_display(p)
- --L425
-- { dep, text }
local next_trains = {}
local function is_past_station(tstn, stnorder)
@@ -728,7 +733,7 @@ function F.ttp_station_display(p)
add_train(train.planned_dep, line, train, id)
elseif not is_past_station(train.location, sttp.station_order) then
-- train is still approaching, calculate arrival time
- local trav_dep = rwt.add(train.initial_dep, (sttp.travel_times[p.station] or 0) + STOP_TIME)
+ local trav_dep = rwt.add(train.initial_dep, (sttp.travel_times[p.station] or 0) + F.STOP_TIME)
local act_dep = rwt.add(trav_dep, train.last_delay)
if p.departure and p.departure[line] then
local plan_dep = rwt.add(train.initial_dep, p.departure[line])
diff --git a/far/nodes/(1753,8,1570).lua b/far/nodes/(1753,8,1570).lua
index de0abbe..7d945dc 100644
--- a/far/nodes/(1753,8,1570).lua
+++ b/far/nodes/(1753,8,1570).lua
@@ -7,7 +7,7 @@ F.save_train(POS(1755,8,1570), "west")
F.ttp_begin({
stn = "Salt Factory", -- station name
tt = "FAR_E", -- timetable ID
- depint = "12;00", --departure slot interval
+ depint = "8;00", --departure slot interval
depoff = "00;00", --departure slot offset
doorside = "L",
reverse = true,
diff --git a/far/nodes/(1771,10,1563).lua b/far/nodes/(1771,10,1563).lua
index 3150a83..a70b572 100644
--- a/far/nodes/(1771,10,1563).lua
+++ b/far/nodes/(1771,10,1563).lua
@@ -1,5 +1,5 @@
F.ttp_station_display({
- lines = {"FAR_W"},
+ lines = {"FAR_W", "FAR_E"},
departure = {},
station = "Salt Factory",
title = "Salt Factory",
diff --git a/far/nodes/(30856,15,1814).lua b/far/nodes/(30856,15,1814).lua
index 21c8a05..919a0cc 100644
--- a/far/nodes/(30856,15,1814).lua
+++ b/far/nodes/(30856,15,1814).lua
@@ -7,7 +7,7 @@ F.save_train(POS(30856,15,1814), "east")
F.ttp_begin({
stn = "Fareast End", -- station name
tt = "FAR_W", -- timetable ID
- depint = "12;00", --departure slot interval
+ depint = "8;00", --departure slot interval
depoff = "00;00", --departure slot offset
doorside = "R",
reverse = false,
diff --git a/far/nodes/(30863,15,1807).lua b/far/nodes/(30863,15,1807).lua
index bdcac10..f42aa48 100644
--- a/far/nodes/(30863,15,1807).lua
+++ b/far/nodes/(30863,15,1807).lua
@@ -7,7 +7,7 @@ F.save_train(POS(30863,15,1807), "east")
F.ttp_begin({
stn = "Fareast End", -- station name
tt = "FAR_W", -- timetable ID
- depint = "12;00", --departure slot interval
+ depint = "8;00", --departure slot interval
depoff = "00;00", --departure slot offset
doorside = "R",
reverse = false,
diff --git a/far/nodes/(30870,15,1800).lua b/far/nodes/(30870,15,1800).lua
index 60180b5..273875d 100644
--- a/far/nodes/(30870,15,1800).lua
+++ b/far/nodes/(30870,15,1800).lua
@@ -7,7 +7,7 @@ F.save_train(POS(30870,15,1800), "east")
F.ttp_begin({
stn = "Fareast End", -- station name
tt = "FAR_W", -- timetable ID
- depint = "12;00", --departure slot interval
+ depint = "8;00", --departure slot interval
depoff = "00;00", --departure slot offset
doorside = "R",
reverse = false,
diff --git a/far/nodes/(5323,32,2321).lua b/far/nodes/(5323,32,2321).lua
new file mode 100644
index 0000000..dccf23d
--- /dev/null
+++ b/far/nodes/(5323,32,2321).lua
@@ -0,0 +1,3 @@
+-- far_luaatctrack_spot_check_01.lua
+
+F.save_train(POS(5323,32,2321), "west")
diff --git a/far/nodes/(5326,32,2311).lua b/far/nodes/(5326,32,2311).lua
new file mode 100644
index 0000000..66c932f
--- /dev/null
+++ b/far/nodes/(5326,32,2311).lua
@@ -0,0 +1,3 @@
+-- far_luaatctrack_spot_check_01.lua
+
+F.save_train(POS(5326,32,2311), "east")
diff --git a/far/nodes/(5409,33,2336).lua b/far/nodes/(5409,33,2336).lua
new file mode 100644
index 0000000..45fd236
--- /dev/null
+++ b/far/nodes/(5409,33,2336).lua
@@ -0,0 +1,3 @@
+-- far_luaatctrack_spot_check_01.lua
+
+F.save_train(POS(5409,33,2336), "west")
diff --git a/far/nodes/(5409,33,2339).lua b/far/nodes/(5409,33,2339).lua
new file mode 100644
index 0000000..25280d4
--- /dev/null
+++ b/far/nodes/(5409,33,2339).lua
@@ -0,0 +1,3 @@
+-- far_luaatctrack_spot_check_01.lua
+
+F.save_train(POS(5409,33,2339), "west")
diff --git a/far/nodes/(5434,33,2329).lua b/far/nodes/(5434,33,2329).lua
new file mode 100644
index 0000000..d550a23
--- /dev/null
+++ b/far/nodes/(5434,33,2329).lua
@@ -0,0 +1,3 @@
+-- far_luaatctrack_spot_check_01.lua
+
+F.save_train(POS(5434,33,2329), "east")
diff --git a/far/nodes/(5434,33,2332).lua b/far/nodes/(5434,33,2332).lua
new file mode 100644
index 0000000..7cf6feb
--- /dev/null
+++ b/far/nodes/(5434,33,2332).lua
@@ -0,0 +1,3 @@
+-- far_luaatctrack_spot_check_01.lua
+
+F.save_train(POS(5434,33,2332), "east")
diff --git a/far/nodes/(5856,21,2314).lua b/far/nodes/(5856,21,2314).lua
new file mode 100644
index 0000000..16b02a4
--- /dev/null
+++ b/far/nodes/(5856,21,2314).lua
@@ -0,0 +1,3 @@
+-- far_luaatctrack_spot_check_01.lua
+
+F.save_train(POS(5856,21,2314), "west")
diff --git a/far/nodes/(5856,21,2315).lua b/far/nodes/(5856,21,2315).lua
deleted file mode 100644
index 9e62790..0000000
--- a/far/nodes/(5856,21,2315).lua
+++ /dev/null
@@ -1,3 +0,0 @@
--- far_luaatctrack_spot_check_01.lua
-
-F.save_train(POS(5856,21,2315), "west")