summaryrefslogtreecommitdiff
path: root/auto_yards/nodes/(-643,26,2475).lua
diff options
context:
space:
mode:
Diffstat (limited to 'auto_yards/nodes/(-643,26,2475).lua')
-rw-r--r--auto_yards/nodes/(-643,26,2475).lua74
1 files changed, 47 insertions, 27 deletions
diff --git a/auto_yards/nodes/(-643,26,2475).lua b/auto_yards/nodes/(-643,26,2475).lua
index 086074b..cd822d6 100644
--- a/auto_yards/nodes/(-643,26,2475).lua
+++ b/auto_yards/nodes/(-643,26,2475).lua
@@ -1,37 +1,50 @@
--- Automatic bouncer for headshunts, assuming longer headshunt than train length. Arrow points into headshunt
-local rev_rc = "CAN_HS_N"
-local rm_rc = true
-local autocouple = "CAN_HS_N_AC"
-local rm_cpl_rc = true
-
-
-__approach_callback_mode = 1
-
-if event.approach and not event.has_entered then
- atc_set_lzb_tsr(3)
- atc_set_ars_disable(true)
- return
-end
+--Cannery Yard Headshunt
+local yard_id = "CAN"
if event.train then
- if not atc_arrow then --train has bounced
- if F.has_rc(autocouple) then
- atc_send("CplS0WD2S1")
- if rm_cpl_rc then F.remove_rc({autocouple}) end
+ if F.has_rc(yard_id.."_LIGHT_EXIT") then return end
+ if F.has_rc(yard_id.."_NOSHUNT") then return end
+ if F.has_rc("CAN_HS_W") then
+ if not atc_arrow then
+ atc_send("B3")
+ schedule_in("0;01", atc_id)
+ return
end
- return
- end
-
- if not F.has_rc(rev_rc) then --not our train. disregard
atc_set_ars_disable(false)
+ F.remove_rc("CAN_HS_W")
+ if F.has_rc("CAN_HS_W_AC") then
+ F.remove_rc("CAN_HS_W_AC")
+ atc_send("S3CplS0D2S3")
+ return
+ end
return
end
- if rm_rc then F.remove_rc({rev_rc}) end
- schedule_in(";01",atc_id)
- return
+ if train_length() == 1 then -- eliminates near half the trains
+ if F.has_rc(yard_id.."_LOCOSTORE") then -- specifies only the relevant train
+ if F.has_rc(yard_id.."_DEPART") and F.has_rc(yard_id.."_FINAL_COLLECT") and F.has_rc(yard_id.."_HEADSHUNT") then --only activate if train is set to depart anyway
+ if not atc_arrow then -- train is pointing towards exit. let it pass and the reverse it
+ atc_set_ars_disable(true)
+ schedule_in(";01",atc_id) -- prepare to reverse the train
+ return
+ else --train has reversed. send it to the siding and deactivate the yard
+ F.remove_rc({yard_id.."_DEPART",yard_id.."_FINAL_COLLECT"})
+ F.add_rc(yard_id.."_send_to_locostore")
+ atc_set_ars_disable(false)
+ F.indicator(S.yards[yard_id].active_indicator_pos, false)
+ S.yards[yard_id].departure_time = rwt.now()
+ S.yards[yard_id].departure_length = S.yards[yard_id].arrival_length
+
+ if S.yards[yard_id].notify_pos then
+ interrupt_pos(S.yards[yard_id].notify_pos,"notify")
+ end
+ return
+ end
+ end
+ end
+ end
end
-if event.schedule then
+if event.schedule then --this is a duplicate of the reversing schedule in the env anyway
if not atc_id then --bounce the train that just passed
atc_send_to_train(event.msg,"B0WRD1A1S3")
else
@@ -40,6 +53,13 @@ if event.schedule then
else -- somehow another train crossed the controller before the first one returned. Unlikely but possible
atc_send_to_train(event.msg,"BBOL")
atc_send("BBOL")
+ F.indicator(yard.error_indicator_pos,true)
end
end
-end \ No newline at end of file
+ return
+end
+
+
+
+-- if all else fails, do a normal headshunt_yard function
+F.headshunt_yard(yard_id,true) \ No newline at end of file