diff options
author | orwell96 <orwell@bleipb.de> | 2018-08-12 16:58:47 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-08-12 16:58:47 +0200 |
commit | a92ecbc26a14a193f103fe6a626eae000fe9b949 (patch) | |
tree | 7a88ed25c10d77eebf73d0f4d9f804b640070993 | |
parent | 0ec89364c01eceb5c47f9cc3503d3561064b7fdb (diff) | |
download | advtrains-a92ecbc26a14a193f103fe6a626eae000fe9b949.tar.gz advtrains-a92ecbc26a14a193f103fe6a626eae000fe9b949.tar.bz2 advtrains-a92ecbc26a14a193f103fe6a626eae000fe9b949.zip |
Automatic working (re-set certain route on train pass)
-rw-r--r-- | advtrains_interlocking/database.lua | 1 | ||||
-rw-r--r-- | advtrains_interlocking/routesetting.lua | 1 | ||||
-rw-r--r-- | advtrains_interlocking/tcb_ts_ui.lua | 11 | ||||
-rw-r--r-- | advtrains_interlocking/train_related.lua | 6 |
4 files changed, 17 insertions, 2 deletions
diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua index c19f516..9fdeeb0 100644 --- a/advtrains_interlocking/database.lua +++ b/advtrains_interlocking/database.lua @@ -140,6 +140,7 @@ TCB data structure aspect = <asp> -- The aspect the signal should show. If this is nil, should show the most restrictive aspect (red) signal_name = <string> -- The human-readable name of the signal, only for documenting purposes routes = { <route definition> } -- a collection of routes from this signal + route_auto = <boolean> -- When set, we will automatically re-set the route (designated by routeset) }, [2] = { -- Variant: end of track-circuited area (initial state of TC) ts_id = nil, -- this is the indication for end_of_interlocking diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua index 1e516a6..bfcfee7 100644 --- a/advtrains_interlocking/routesetting.lua +++ b/advtrains_interlocking/routesetting.lua @@ -253,6 +253,7 @@ function ilrs.update_route(sigd, tcbs, newrte, cancel) end tcbs.route_committed = nil tcbs.routeset = newrte + tcbs.route_auto = nil end if newrte or tcbs.routeset then if newrte then tcbs.routeset = newrte end diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua index 0df3d3a..3b9a3ac 100644 --- a/advtrains_interlocking/tcb_ts_ui.lua +++ b/advtrains_interlocking/tcb_ts_ui.lua @@ -471,6 +471,12 @@ function advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte) form = form.."label[0.5,4;"..tcbs.route_rsn.."]" end end + if not tcbs.route_auto then + form = form.."button[0.5,4.5; 5,1;auto;Enable Automatic Working]" + else + form = form.."label[0.5,4.5;Automatic Working is active.]" + form = form.."label[0.5,4.8;Route is re-set when a train passed.]" + end form = form.."button[0.5,6; 5,1;cancelroute;Cancel Route]" else @@ -526,7 +532,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end if tcbs.routeset and fields.cancelroute then -- if route committed, cancel route ts info - ilrs.update_route(sigd, tcbs, nil, true) end if not tcbs.routeset then @@ -573,6 +578,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end + if fields.auto then + tcbs.route_auto = true + end + advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte) return end diff --git a/advtrains_interlocking/train_related.lua b/advtrains_interlocking/train_related.lua index ebeda9f..a92e18f 100644 --- a/advtrains_interlocking/train_related.lua +++ b/advtrains_interlocking/train_related.lua @@ -79,10 +79,14 @@ local function setsection(tid, train, ts_id, ts, origin) -- this is the first route section. clear route status from origin sigd local tcbs = advtrains.interlocking.db.get_tcbs(ts.route.origin) if tcbs then - tcbs.routeset = nil tcbs.route_committed = nil tcbs.aspect = nil advtrains.interlocking.update_signal_aspect(tcbs) + if tcbs.route_auto then + advtrains.interlocking.route.update_route(ts.route.origin, tcbs) + else + tcbs.routeset = nil + end end end ts.route = nil |