diff options
Diffstat (limited to 'advtrains_interlocking/tcb_ts_ui.lua')
-rwxr-xr-x | advtrains_interlocking/tcb_ts_ui.lua | 35 |
1 files changed, 31 insertions, 4 deletions
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 |