aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/route_prog.lua27
-rw-r--r--advtrains_interlocking/route_ui.lua14
-rw-r--r--advtrains_interlocking/routesetting.lua8
-rwxr-xr-xadvtrains_interlocking/tcb_ts_ui.lua35
-rw-r--r--advtrains_interlocking/tsr_rail.lua12
5 files changed, 76 insertions, 20 deletions
diff --git a/advtrains_interlocking/route_prog.lua b/advtrains_interlocking/route_prog.lua
index 37f751a..3ab5686 100644
--- a/advtrains_interlocking/route_prog.lua
+++ b/advtrains_interlocking/route_prog.lua
@@ -219,19 +219,32 @@ end
local player_rte_prog = {}
-function advtrains.interlocking.init_route_prog(pname, sigd)
+function advtrains.interlocking.init_route_prog(pname, sigd, default_route)
if not minetest.check_player_privs(pname, "interlocking") then
minetest.chat_send_player(pname, "Insufficient privileges to use this!")
return
end
- player_rte_prog[pname] = {
+ local rp = {
origin = sigd,
- route = {
- name = "PROG["..pname.."]",
- },
- tmp_lcks = {},
}
- advtrains.interlocking.visualize_route(sigd, player_rte_prog[pname].route, "prog_"..pname, player_rte_prog[pname].tmp_lcks, pname)
+ if default_route then
+ rp.route = table.copy(default_route)
+
+ -- "Step back one section", but keeping turnouts
+ local last_route = rp.route[#rp.route]
+ if last_route then
+ rp.tmp_lcks = last_route.locks
+ rp.route[#rp.route] = nil
+ end
+ rp.route.name = "PROG["..pname.."]"
+ else
+ rp.route = {
+ name = "PROG["..pname.."]"
+ }
+ rp.tmp_lcks = {}
+ end
+ player_rte_prog[pname] = rp
+ advtrains.interlocking.visualize_route(sigd, rp.route, "prog_"..pname, rp.tmp_lcks, pname)
minetest.chat_send_player(pname, "Route programming mode active. Punch TCBs to add route segments, punch turnouts to lock them.")
end
diff --git a/advtrains_interlocking/route_ui.lua b/advtrains_interlocking/route_ui.lua
index b01d449..478e8dc 100644
--- a/advtrains_interlocking/route_ui.lua
+++ b/advtrains_interlocking/route_ui.lua
@@ -25,7 +25,7 @@ function atil.show_route_edit_form(pname, sigd, routeid)
local route = tcbs.routes[routeid]
if not route then return end
- local form = "size[9,10]label[0.5,0.2;Route overview]"
+ local form = "size[9,11]label[0.5,0.2;Route overview]"
form = form.."field[0.8,1.2;6.5,1;name;Route name;"..minetest.formspec_escape(route.name).."]"
form = form.."button[7.0,0.9;1.5,1;setname;Set]"
@@ -114,11 +114,12 @@ function atil.show_route_edit_form(pname, sigd, routeid)
form = form.."button[3.5,6;2,1;noautogen;Clr Autogen]"
end
form = form.."button[5.5,6;3,1;delete;Delete Route]"
+ form = form.."button[5.5,7;3,1;newfrom;New From Route]"
--atdebug(route.ars)
form = form.."style[ars;font=mono]"
- form = form.."textarea[0.8,7.3;5,3;ars;ARS Rule List;"..atil.ars_to_text(route.ars).."]"
- form = form.."button[5.5,7.23;3,1;savears;Save ARS List]"
+ form = form.."textarea[0.8,8.3;5,3;ars;ARS Rule List;"..atil.ars_to_text(route.ars).."]"
+ form = form.."button[5.5,8.23;3,1;savears;Save ARS List]"
minetest.show_formspec(pname, "at_il_routeedit_"..minetest.pos_to_string(sigd.p).."_"..sigd.s.."_"..routeid, form)
@@ -185,6 +186,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
table.remove(tcbs.routes, routeid)
advtrains.interlocking.show_signalling_form(sigd, pname)
end
+
+ if fields.newfrom then
+ advtrains.interlocking.init_route_prog(pname, sigd, route)
+ minetest.close_formspec(pname, formname)
+ tcbs.ars_ignore_next = nil
+ return
+ end
if fields.ars and fields.savears then
route.ars = atil.text_to_ars(fields.ars)
diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua
index 0207519..a72f644 100644
--- a/advtrains_interlocking/routesetting.lua
+++ b/advtrains_interlocking/routesetting.lua
@@ -365,7 +365,13 @@ function ilrs.update_route(sigd, tcbs, newrte, cancel)
end
if newrte then tcbs.routeset = newrte end
--atdebug("Setting:",tcbs.routeset)
- local succ, rsn, cbts, cblk = ilrs.set_route(sigd, tcbs.routes[tcbs.routeset])
+ local succ, rsn, cbts, cblk
+ if tcbs.routes[tcbs.routeset] then
+ succ, rsn, cbts, cblk = ilrs.set_route(sigd, tcbs.routes[tcbs.routeset])
+ else
+ succ = false
+ rsn = attrans("Route state changed.")
+ end
if not succ then
tcbs.route_rsn = rsn
--atdebug("Routesetting failed:",rsn)
diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua
index 82a57cf..e7ff685 100755
--- a/advtrains_interlocking/tcb_ts_ui.lua
+++ b/advtrains_interlocking/tcb_ts_ui.lua
@@ -494,6 +494,13 @@ minetest.register_entity("advtrains_interlocking:tcbmarker", {
static_save = false,
})
+function advtrains.interlocking.remove_tcb_marker_pts(pts)
+ if markerent[pts] then
+ markerent[pts]:remove()
+ markerent[pts] = nil
+ end
+end
+
function advtrains.interlocking.show_tcb_marker(pos)
--atdebug("showing tcb marker",pos)
local tcb = ildb.get_tcb(pos)
@@ -517,9 +524,7 @@ function advtrains.interlocking.show_tcb_marker(pos)
end
local pts = advtrains.roundfloorpts(pos)
- if markerent[pts] then
- markerent[pts]:remove()
- end
+ advtrains.interlocking.remove_tcb_marker_pts(pts)
local obj = minetest.add_entity(pos, "advtrains_interlocking:tcbmarker")
if not obj then return end
@@ -628,14 +633,22 @@ function advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte, calle
strtab[#strtab+1] = clr .. minetest.formspec_escape(route.name)
end
form = form.."label[0.5,2.5;Routes:]"
- form = form.."textlist[0.5,3;5,3;rtelist;"..table.concat(strtab, ",").."]"
+ form = form.."textlist[0.5,3;5,3;rtelist;"..table.concat(strtab, ",")
if sel_rte then
+ form = form .. ";" .. sel_rte .."]"
form = form.."button[0.5,6; 5,1;setroute;Set Route]"
form = form.."button[0.5,7;2,1;dsproute;Show]"
if hasprivs then
form = form.."button[3.5,7;2,1;editroute;Edit]"
+ if sel_rte > 1 then
+ form = form .. "button[5.5,4;0.5,0.3;moveup;↑]"
+ end
+ if sel_rte < #strtab then
+ form = form .. "button[5.5,4.7;0.5,0.3;movedown;↓]"
+ end
end
else
+ form = form .. "]"
if tcbs.ars_disabled then
form = form.."label[0.5,6 ;NOTE: ARS is disabled.]"
form = form.."label[0.5,6.5;Routes are not automatically set.]"
@@ -772,6 +785,20 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.noauto then
tcbs.route_auto = false
end
+
+ if sel_rte and tcbs.routes[sel_rte]and not tcbs.routeset then
+ if fields.moveup then
+ if tcbs.routes[sel_rte - 1] then
+ tcbs.routes[sel_rte - 1], tcbs.routes[sel_rte] = tcbs.routes[sel_rte], tcbs.routes[sel_rte - 1]
+ sel_rte = sel_rte - 1
+ end
+ elseif fields.movedown then
+ if tcbs.routes[sel_rte + 1] then
+ tcbs.routes[sel_rte + 1], tcbs.routes[sel_rte] = tcbs.routes[sel_rte], tcbs.routes[sel_rte + 1]
+ sel_rte = sel_rte + 1
+ end
+ end
+ end
advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte, true)
return
diff --git a/advtrains_interlocking/tsr_rail.lua b/advtrains_interlocking/tsr_rail.lua
index f302540..c1e3c1c 100644
--- a/advtrains_interlocking/tsr_rail.lua
+++ b/advtrains_interlocking/tsr_rail.lua
@@ -3,13 +3,15 @@
-- Simple rail whose only purpose is to place a TSR on the position, as a temporary solution until the timetable system covers everything.
-- This code resembles the code in lines/stoprail.lua
+local S = attrans
+
local function updateform(pos)
local meta = minetest.get_meta(pos)
local pe = advtrains.encode_pos(pos)
local npr = advtrains.interlocking.npr_rails[pe] or 2
- meta:set_string("infotext", "Point speed restriction: "..npr)
- meta:set_string("formspec", "field[npr;Set point speed restriction:;"..npr.."]")
+ meta:set_string("infotext", S("Point speed restriction: @1",npr))
+ meta:set_string("formspec", "field[npr;"..S("Set point speed restriction:")..";"..npr.."]")
end
@@ -25,11 +27,11 @@ local adefunc = function(def, preset, suffix, rotation)
on_receive_fields = function(pos, formname, fields, player)
local pname = player:get_player_name()
if not minetest.check_player_privs(pname, {interlocking=true}) then
- minetest.chat_send_player(pname, "Interlocking privilege required!")
+ minetest.chat_send_player(pname, S("You are not allowed to configure this track without the @1 privilege.", "interlocking"))
return
end
if minetest.is_protected(pos, pname) then
- minetest.chat_send_player(pname, "This rail is protected!")
+ minetest.chat_send_player(pname, S("You are not allowed to configure this track."))
minetest.record_protection_violation(pos, pname)
return
end
@@ -59,7 +61,7 @@ if minetest.get_modpath("advtrains_train_track") ~= nil then
models_prefix="advtrains_dtrack",
models_suffix=".b3d",
shared_texture="advtrains_dtrack_shared_npr.png",
- description="Point Speed Restriction Rail",
+ description=S("Point Speed Restriction Track"),
formats={},
get_additional_definiton = adefunc,
}, advtrains.trackpresets.t_30deg_straightonly)