aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/route_ui.lua
diff options
context:
space:
mode:
authororwell <orwell@bleipb.de>2024-11-13 20:51:04 +0100
committerorwell <orwell@bleipb.de>2024-11-13 20:51:04 +0100
commitd42f1bcf1a7ec18d392671be54636e7cad8b788b (patch)
tree05a35421b85eae486ab72bf9b39b2e1be107d200 /advtrains_interlocking/route_ui.lua
parent5fb6732f8d8b38bbb1894466a367704886451f1a (diff)
downloadadvtrains-d42f1bcf1a7ec18d392671be54636e7cad8b788b.tar.gz
advtrains-d42f1bcf1a7ec18d392671be54636e7cad8b788b.tar.bz2
advtrains-d42f1bcf1a7ec18d392671be54636e7cad8b788b.zip
Route edit UI: option to copy route in place
Diffstat (limited to 'advtrains_interlocking/route_ui.lua')
-rw-r--r--advtrains_interlocking/route_ui.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/advtrains_interlocking/route_ui.lua b/advtrains_interlocking/route_ui.lua
index 478e8dc..89580a8 100644
--- a/advtrains_interlocking/route_ui.lua
+++ b/advtrains_interlocking/route_ui.lua
@@ -106,7 +106,7 @@ function atil.show_route_edit_form(pname, sigd, routeid)
end
form = form.."button[0.5,6;1,1;prev;<<<]"
- form = form.."button[1.5,6;1,1;back;Back]"
+ form = form.."button[1.5,6;1,1;back;"..routeid.."/"..#tcbs.routes.."]"
form = form.."button[2.5,6;1,1;next;>>>]"
@@ -114,6 +114,8 @@ 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[0.5,7;3,1;back;Back to signal]"
+ form = form.."button[3.5,7;2,1;clone;Clone Route]"
form = form.."button[5.5,7;3,1;newfrom;New From Route]"
--atdebug(route.ars)
@@ -186,6 +188,16 @@ 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.clone then
+ -- if something set the route in the meantime, make sure this doesn't break.
+ atil.route.update_route(sigd, tcbs, nil, true)
+ local rcopy = table.copy(route)
+ rcopy.name = route.name.."_copy"
+ rcopy.smartroute_generated = nil
+ table.insert(tcbs.routes, routeid+1, rcopy)
+ advtrains.interlocking.show_signalling_form(sigd, pname)
+ end
if fields.newfrom then
advtrains.interlocking.init_route_prog(pname, sigd, route)