aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-03-13 11:11:12 +0100
committerorwell96 <orwell@bleipb.de>2021-03-13 11:13:13 +0100
commit682ff59906218a78f0fa7408ab05ed5746d732e2 (patch)
tree32960d265639eaa81421126ebd8e87ee1351be5b /advtrains_line_automation
parentb2d7bbb2c577a2b28cdaf421daf9b143f4376c8a (diff)
Replace deprecated depends.txt's by mod.conf and organize dependencies consistently, add modpack.conf
Diffstat (limited to 'advtrains_line_automation')
-rw-r--r--advtrains_line_automation/depends.txt2
-rw-r--r--advtrains_line_automation/mod.conf7
2 files changed, 7 insertions, 2 deletions
diff --git a/advtrains_line_automation/depends.txt b/advtrains_line_automation/depends.txt
deleted file mode 100644
index ce2e23c..0000000
--- a/advtrains_line_automation/depends.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-advtrains_interlocking
-advtrains_train_track? \ No newline at end of file
diff --git a/advtrains_line_automation/mod.conf b/advtrains_line_automation/mod.conf
new file mode 100644
index 0000000..e9851c8
--- /dev/null
+++ b/advtrains_line_automation/mod.conf
@@ -0,0 +1,7 @@
+name=advtrains_line_automation
+title=Advanced Trains Line Automation
+description=Tools for automatic train lines
+author=orwell96
+
+depends=advtrains_interlocking
+optional_depends=advtrains_train_track
">== 0 and minetest.settings:get_bool("at_il_force_lzb_halt") then atwarn(id,"overrun LZB 0 restriction (red signal) ",pos) -- Set train 1 index backward. Hope this does not lead to bugs... --train.index = index - 0.5 advtrains.speed.set_restriction(train, "main", 0) --TODO temporary --advtrains.drb_dump(id) --error("Debug: "..id.." triggered LZB-0") else advtrains.speed.set_restriction(train, asptype, speed or -1) train.is_shunt = shunt end --atdebug("train drove over IP: speed=",speed,"shunt=",shunt) end end advtrains.tnc_register_on_approach(function(pos, id, train, index, has_entered, lzbdata) --atdebug(id,"IL ApprC",pos,index,lzbdata) --train.debug = advtrains.print_concat_table({train.is_shunt,"|",index,"|",lzbdata}) local pts = advtrains.roundfloorpts(pos) local cn = train.path_cn[index] local travsht = lzbdata.il_shunt local travspd = lzbdata.il_speed if travsht==nil then -- lzbdata has reset travspd = train.speed_restriction travsht = train.is_shunt or false end -- check for signal local asp, spos = il.db.get_ip_signal_asp(pts, cn) -- do ARS if needed local ars_enabled = not train.ars_disable -- Note on ars_disable: -- Theoretically, the ars_disable flag would need to behave like the speed restriction field: it should be -- stored in lzbdata and updated once the train drives over. However, for the sake of simplicity, it is simply -- a value in the train. In this case, this is sufficient because once a train triggers ARS for the first time, -- resetting the path does not matter to the set route and ARS doesn't need to be called again. if spos and ars_enabled then --atdebug(id,"IL Spos (ARS)",spos,asp) il.ars_check(spos, train) end --atdebug("trav: ",pos, cn, asp, spos, "travsht=", lzb.travsht) local lspd if asp then --atdebug(id,"IL Signal",spos, asp, lzbdata, "trainstate", train.speed_restriction, train.is_shunt) local nspd = 0 --interpreting aspect and determining speed to proceed if travsht then --shunt move if asp.shunt then nspd = SHUNT_SPEED_MAX elseif asp.proceed_as_main and asp.main ~= 0 then nspd = asp.main travsht = false end else --train move if asp.main ~= 0 then nspd = asp.main elseif asp.shunt then nspd = SHUNT_SPEED_MAX travsht = true end end -- nspd can now be: 1. !=0: new speed restriction, 2. =0: stop here or 3. nil: keep travspd if nspd then travspd = nspd if nspd == -1 then travspd = nil else travspd = nspd end end --atdebug("ns,ts", nspd, travspd) lspd = travspd local udata = {signal_pos = spos} local callback = get_over_function(lspd, travsht, asp.type) lzbdata.il_shunt = travsht lzbdata.il_speed = travspd --atdebug("new lzbdata",lzbdata) advtrains.lzb_add_checkpoint(train, index, lspd, callback, lzbdata, udata) end end) -- Set the ars_disable flag to the value passed -- Triggers a path invalidation if set to false function advtrains.interlocking.ars_set_disable(train, value) if value then train.ars_disable = true else train.ars_disable = nil minetest.after(0, advtrains.path_invalidate, train) end end