summaryrefslogtreecommitdiff
path: root/auto_yards/nodes/(-643,26,2475).lua
diff options
context:
space:
mode:
authorautocommitter <autocommitter@linux-forks.de>2024-04-22 14:58:03 +0200
committerautocommitter <autocommitter@linux-forks.de>2024-04-22 14:58:03 +0200
commit7b3ac07f3f9b9d92582aceb74050215a36646bc5 (patch)
tree3eda9d8e0a85b9d0daa53dd2887d154d9e0ef172 /auto_yards/nodes/(-643,26,2475).lua
parentefa99edcbd392873d8ed78eae7760f8c0b23dc45 (diff)
downloadluaatc_envs-7b3ac07f3f9b9d92582aceb74050215a36646bc5.tar.gz
luaatc_envs-7b3ac07f3f9b9d92582aceb74050215a36646bc5.tar.bz2
luaatc_envs-7b3ac07f3f9b9d92582aceb74050215a36646bc5.zip
State at 2023-03-26
Diffstat (limited to 'auto_yards/nodes/(-643,26,2475).lua')
-rw-r--r--auto_yards/nodes/(-643,26,2475).lua83
1 files changed, 83 insertions, 0 deletions
diff --git a/auto_yards/nodes/(-643,26,2475).lua b/auto_yards/nodes/(-643,26,2475).lua
new file mode 100644
index 0000000..1523fcd
--- /dev/null
+++ b/auto_yards/nodes/(-643,26,2475).lua
@@ -0,0 +1,83 @@
+local yard_id = "CAN"
+
+
+if event.train then
+ 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_SHUFFLE") then -- train is consolidating wagons for export to ARC
+ if not atc_arrow then
+ schedule_in(";01",atc_id) -- prepare to reverse the train
+ return
+ end
+ print(F.get_rc_safe())
+ F.remove_rc_match("CAN_CLASS_%S+")
+ F.remove_rc_match("CAN_COLLECT_%S+")
+ F.remove_rc("CAN_PICKUP CAN_HEADSHUNT CAN_FINAL_COLLECT")
+ local stage_list = {
+ "CAN_CLASS_ETHANOL CAN_COLLECT_ETHANOL CAN_FINAL_COLLECT",
+ "CAN_CLASS_ARC",
+ "CAN_CLASS_CORN CAN_COLLECT_CORN CAN_FINAL_COLLECT",
+ "CAN_CLASS_ARC",
+ "CAN_send_to_locostore"
+ }
+ F.add_rc(stage_list[S.yards[yard_id].shuffle_stage])
+ print(F.get_rc_safe())
+ print(S.yards[yard_id].shuffle_stage)
+ set_autocouple()
+ atc_set_ars_disable(false)
+
+ if S.yards[yard_id].shuffle_stage == #stage_list then -- loco is returning to storage. release the yard
+ F.indicator(S.yards[yard_id].active_indicator_pos,false)
+ S.yards[yard_id].notify.ARC = true
+ interrupt_pos(S.yards[yard_id].notify_pos)
+ else
+ S.yards[yard_id].shuffle_stage = S.yards[yard_id].shuffle_stage + 1
+ end
+ return
+ end
+
+ 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 --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
+ if atc_id == event.msg then --train hasn't fully passed yet, wait a bit longer
+ schedule_in(";01",atc_id)
+ 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
+ return
+end
+
+
+
+-- if all else fails, do a normal headshunt_yard function
+F.headshunt_yard(yard_id,true) \ No newline at end of file