From ae394a43b8a715570ee3b94b19e70b8d66f597e4 Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sun, 30 Jun 2024 06:20:42 +0800 Subject: Remove TCB marker on TCB removal This patch fixes the following problem: * TCB marker is not removed on TCB removal * TCB marker is recreated on removal --- advtrains_interlocking/tcb_ts_ui.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'advtrains_interlocking/tcb_ts_ui.lua') diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua index 0cc10da..96edadb 100755 --- a/advtrains_interlocking/tcb_ts_ui.lua +++ b/advtrains_interlocking/tcb_ts_ui.lua @@ -550,6 +550,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) @@ -573,9 +580,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 -- cgit v1.2.3 From ca4084df86527d98c738fb1f731ffdaa32936c91 Mon Sep 17 00:00:00 2001 From: 1F616EMO Date: Sun, 8 Sep 2024 07:19:32 +0800 Subject: Allow manually sorting of signal soutes This patch adds two buttons to the signal UI for swapping routes in the list of routes. To prevent conflicts, this operation is only possible when there is no route set. --- advtrains_interlocking/tcb_ts_ui.lua | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'advtrains_interlocking/tcb_ts_ui.lua') diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua index 96edadb..264834c 100755 --- a/advtrains_interlocking/tcb_ts_ui.lua +++ b/advtrains_interlocking/tcb_ts_ui.lua @@ -657,14 +657,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.]" @@ -815,6 +823,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 -- cgit v1.2.3