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).lua88
1 files changed, 51 insertions, 37 deletions
diff --git a/auto_yards/nodes/(-630,26,2454).lua b/auto_yards/nodes/(-630,26,2454).lua
index 5715c34..8dd1ff7 100644
--- a/auto_yards/nodes/(-630,26,2454).lua
+++ b/auto_yards/nodes/(-630,26,2454).lua
@@ -1,22 +1,53 @@
+-- Cannery Loco Storage
local notification_id = "CAN"
-local ind = POS(-594,26,2488)
-local shuffle_ind = POS(-594,26,2487)
+local ind = POS(-594,26,2488) --notification indicator
+local sand_indicator = POS(-572,26,2515) --sand indicator
local print_notification = true
+
+local sections = {
+ clay_factory = "327479",
+ departures = "484515"
+}
+
local function send_train()
- set_rc("FREIGHT CAN_LOCOSTORE CAN_LIGHT_EXIT EWL-W EWL S23 ARC_AUTO ARC_RTS ARC_COLLECT_CANNERY ARC_AUTO_S23N CANNERY CAN_RTS CAN_COLLECT_ARC")
+ if F.indicator(S.yards[notification_id].active_indicator_pos) then -- another train already in the yard. wait for it to exit first
+ print("yard still active")
+ schedule_in("0;2","send_train")
+ return
+ end
+ print("Sending Train")
+ local base_rc = {
+ "FREIGHT",
+ "CAN_LOCOSTORE",
+ "EWL-W",
+ "EWL",
+ "S23",
+ "ARC_AUTO",
+ "ARC_COLLECT_CANNERY",
+ "ARC_AUTO_S23N",
+ "CANNERY",
+ "CAN_COLLECT_DEPARTURES"
+ }
+ if section_occupancy(sections.clay_factory)[1] and F.indicator(sand_indicator) then
+ -- step the dirt wagons forward into sand wagons
+ print("Reshuffling sand export before departure")
+ base_rc[#base_rc+1] = "CAN_INTRA_SHUFFLE"
+ base_rc[#base_rc+1] = "CAN_HS_W"
+ base_rc[#base_rc+1] = "CAN_HS_W_AC"
+ base_rc[#base_rc+1] = "CAN_CLASS_DIRT_UNLOAD"
+ F.indicator(S.yards.CAN.active_indicator_pos, true) --activate the yard to prevent other trains entering while we're moving around
+ elseif section_occupancy(sections.departures)[1] then --collect departures wagons before departing proper
+ base_rc[#base_rc+1] = "CAN_REENTER_YARD"
+ print("Collecting Departures")
+ else
+ base_rc[#base_rc+1] = "CAN_LIGHT_EXIT"
+ end
+ print("rc list set")
+ set_rc(table.concat(base_rc," "))
+ print("rc set")
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
+ print("train sent")
end
if event.ext_int then
@@ -30,44 +61,27 @@ if event.ext_int then
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
+ return
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")
+ if event.msg=="send_train" then
+ send_train()
return
end
return
end
if event.train then
- unset_autocouple()
- if F.indicator(shuffle_ind) then
- shuffle_wagons()
- return
- end
+ print("Train arrived")
if F.indicator(ind) then
+ print("indicator on. Sending Train")
send_train()
return
end
+ print("train movements completed")
atc_send("B0")
return
end \ No newline at end of file