summaryrefslogtreecommitdiff
path: root/auto_yards/nodes/(-630,26,2454).lua
diff options
context:
space:
mode:
Diffstat (limited to 'auto_yards/nodes/(-630,26,2454).lua')
-rw-r--r--auto_yards/nodes/(-630,26,2454).lua73
1 files changed, 73 insertions, 0 deletions
diff --git a/auto_yards/nodes/(-630,26,2454).lua b/auto_yards/nodes/(-630,26,2454).lua
new file mode 100644
index 0000000..e01fb60
--- /dev/null
+++ b/auto_yards/nodes/(-630,26,2454).lua
@@ -0,0 +1,73 @@
+local notification_id = "CAN"
+local ind = POS(-594,26,2488)
+local shuffle_ind = POS(-594,26,2487)
+local print_notification = true
+local function send_train()
+ set_rc("FREIGHT CAN_LOCOSTORE CAN_LIGHT_EXIT EWL-W EWL S23 ARCAUTO ARC_RTS ARC_COLLECT_CANNERY ARC_AUTO_S23N CANNERY CAN_RTS CAN_COLLECT_ARC")
+ atc_send("S0WRD2A1S4")
+ F.indicator(ind,false)
+end
+
+local function shuffle_wagons()
+ F.indicator(S.yards[notification_id].active_indicator_pos, true) --stop other trains entering the yard
+ F.indicator(S.yards[notification_id].dir_indicator_pos,true)
+ F.indicator(shuffle_ind,false)
+ F.indicator(ind,true)
+ S.yards[notification_id].shuffle_stage = 1 -- set a shuffle stage counter
+ set_rc("CAN_LOCOSTORE CAN_SHUFFLE")
+ atc_send("S0WRD2A1S4") --send train to headshunt
+ return
+end
+
+if event.ext_int then
+ if event.message == "notify" then
+ if print_notification then print(rwt.to_string(rwt.now()).. " "..notification_id.." RX Notification") end
+ if F.indicator(ind) then return end
+ if atc_id then
+ send_train()
+ return
+ else
+ F.indicator(ind,true)
+ return
+ end
+ elseif event.message == "shuffle" then
+ if atc_id then
+ if not F.indicator(S.yards[notification_id].active_indicator_pos) then
+ shuffle_wagons()
+ return
+ end
+ schedule_in(":05","shuffle")
+ return
+ else
+ F.indicator(shuffle_ind,true)
+ return
+ end
+ end
+ return
+end
+
+if event.schedule then
+ if event.message=="shuffle" then
+ if not F.idicator(S.yards[notification_id].active_indicator_pos) then
+ shuffle_wagons()
+ return
+ end
+ schedule_in(":05","shuffle")
+ return
+ end
+ return
+end
+
+if event.train then
+ unset_autocouple()
+ if F.indicator(shuffle_ind) then
+ shuffle_wagons()
+ return
+ end
+ if F.indicator(ind) then
+ send_train()
+ return
+ end
+ atc_send("B0")
+ return
+end \ No newline at end of file