aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
authororwell <orwell@bleipb.de>2024-11-11 20:50:28 +0100
committerorwell <orwell@bleipb.de>2024-11-11 20:50:28 +0100
commit380c26f7a851f4b4edb3879b544a542e7bfbb490 (patch)
tree158ac366c93a8581f5792f95eba6932bafe4c325 /advtrains_interlocking
parent29180f0f60871f92889f686fe666c029ac07861a (diff)
parent3d2d19f6f7eba90f0d19b002824b2ff466567608 (diff)
Merge branch 'master' into route_prog_rework
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)
n signal is assigned (either by user or by route): main_aspect is always { name = "_default" } and rem_aspect / rem_aspinfo give the correct information Main aspect names starting with underscore (e.g. "_default") are reserved and must not be used! == Aspect Info == The actual signal aspect in the already-known format. This is what the trains use to determine halt/proceed and speed. asp = { main = 0 (halt) / -1 (max speed) / false (no info) / <number> (speed limit) shunt = true (shunt free) / false (shunt not free) proceed_as_main = true (shunt move can proceed and become train move when main!=0) / false (no) dst = speed of the remote signal (like main, informative character, not actually used) } Node definition of signals: - The signal needs some logic to figure out, for each combination of its own aspect group and the distant signal's aspect, what aspect info it can/will show. ndef.advtrains = { main_aspects = { { name = "proceed" description = "Proceed at full speed", <more data at discretion of signal>} { name = "reduced" description = "Proceed at reduced speed", <more data at discretion of signal>} } -- This list is mainly for the selection dialog. Order of entries determines list order in the dropdown. -- Some fields have special meaning: -- name: A unique key to identify the main aspect. Might be required by some code. -- description: Text shown in UI dropdown -- Node can set any other fields at its discretion. They are not touched. -- Note: Pure distant signals (that cannot show halt) should NOT have a main_aspects table. -- For these signals no main aspect selection UI is shown and they cannot be startpoint of a route apply_aspect = function(pos, node, main_aspect, rem_aspect, rem_aspinfo) -- set the node to show the desired aspect -- called by advtrains when this signal's aspect group or the remote signal's aspect changes -- main_aspect is never nil, but can be one of the special aspects { halt = true } or { default = true } -- MAY return the aspect_info. If it returns nil then get_aspect_info will be queried at a later point. get_aspect_info(pos, main_aspect) -- Returns the aspect info table (main, shunt, dst etc.) distant_support = true or false -- If true, signal is considered in distant signalling. If false or nil, rem_aspect and rem_aspinfo are never set. route_role = one of "main", "main_distant", "shunt", "distant", "distant_repeater", "end" -- Determines how the signal behaves when routes are set. Only in effect when signal is assigned to a TCB. -- main: The signal is a possible endpoint for a train move route. Distant signals before it refer to it. -- shunt: The signal is a possible endpoint for a shunt move route. Ignored for distant signals. -- distant, distant_repeater: When route is set, signal is always assigned its first main aspect. The next signal with role="main" is set as the remote signal. (currently no further distinction) -- main_distant: Combination of main and distant - like "main", but additionally gets assigned to the next main like a "distant" -- end: like main, but signifies that it marks an end of track and trains cannot continue further. (currently no practical implications above main) } == Nomenclature == The distant/main relation is named as follows: V M =====>====> Main signal (main) always refers to the signal that is in focus right now (even if that is a distant-only signal) From the standpoint of M, V is the distant (dst) signal. M does not need to concern itself with V's aspect but needs to notify V when it changes From the standpoint of V, M is the remote (rem) signal. V needs to show an aspect that matches its remote signal M == Criteria for which signals are eligible for routes == All signals must define: - get_aspect_info() Signals that can be assigned to a TCB must satisfy: - apply_aspect() defined Signals that are possible start and end points for a route must satisfy: - main_aspects defined (note, pure distant signals should therefore not define main_aspects) ]] -- Database -- Signal Aspect store -- Stores for each signal the main aspect and other info, like the assigned remote signal -- [signal encodePos] = { main = <table or string>, [remote = encodedPos] } -- main is a string: "named aspect" is looked up in the main_aspects table of the ndef -- main is a table: this table directly is the main aspect (used for advanced signals with additional lights/indicators) signal.aspects = {} -- Distant signal notification. Records for each signal the distant signals that refer to it -- Note: this mapping is weak. Needs always backreference check. -- [signal encodePos] = { [distant signal encodePos] = true } signal.distant_refs = {} function signal.load(data) signal.aspects = data.aspects or {} -- rebuild distant_refs after load signal.distant_refs = {} for main, aspt in pairs(signal.aspects) do if aspt.remote then if not signal.distant_refs[aspt.remote] then signal.distant_refs[aspt.remote] = {} end signal.distant_refs[aspt.remote][main] = true end end end function signal.save(data) data.aspects = signal.aspects end -- Set a signal's aspect. -- Signal aspects should only be set through this function. It takes care of: -- - Storing the main aspect and dst pos for this signal permanently (until next change) -- - Assigning the distant signal for this signal -- - Calling apply_aspect() in the signal's node definition to make the signal show the aspect -- - Calling apply_aspect() again whenever the remote signal changes its aspect -- - Notifying this signal's distant signals about changes to this signal (unless skip_dst_notify is specified) -- main_asp: either a string (==name in ndef.advtrains.main_aspects) or the main aspect table directly (for advanced signals) function signal.set_aspect(pos, main_asp, rem_pos, skip_dst_notify) -- safeguard for the two integrated aspects (these two must be passed as string key) if type(main_asp)=="table" and (main_asp.name=="_default" or main_asp.name=="_halt") then error("MASP_HALT and MASP_DEFAULT must be passed via string keys _halt or _default, not as tables!") end local main_pts = advtrains.encode_pos(pos) local old_tbl = signal.aspects[main_pts] local old_remote = old_tbl and old_tbl.remote local new_remote = rem_pos and advtrains.encode_pos(rem_pos) -- if remote has changed, unregister from old remote if old_remote and old_remote~=new_remote and signal.distant_refs[old_remote] then atdebug("unregister old remote: ",old_remote,"from",main_pts) signal.distant_refs[old_remote][main_pts] = nil end signal.aspects[main_pts] = { main = main_asp, remote = new_remote } -- apply aspect on main signal, this also checks new_remote signal.reapply_aspect(main_pts) -- notify my distants about this change (with limit 2) if not skip_dst_notify then signal.notify_distants_of(main_pts, 2) end end function signal.clear_aspect(pos, skip_dst_notify) local main_pts = advtrains.encode_pos(pos) local old_tbl = signal.aspects[main_pts] local old_remote = old_tbl and old_tbl.remote -- unregister from old remote if old_remote then signal.distant_refs[old_remote][main_pts] = nil end signal.aspects[main_pts] = nil -- apply aspect on main signal, this also checks new_remote signal.reapply_aspect(main_pts) -- notify my distants about this change (with limit 2) if not skip_dst_notify then signal.notify_distants_of(main_pts, 2) end end -- Clear any info about aspects from this signal, without resetting/reapplying the aspect. -- Supposed to be used for legacy on-off signals when the on-off toggle is used function signal.unregister_aspect(pos) local main_pts = advtrains.encode_pos(pos) local old_tbl = signal.aspects[main_pts] local old_remote = old_tbl and old_tbl.remote -- unregister from old remote if old_remote then signal.distant_refs[old_remote][main_pts] = nil end signal.aspects[main_pts] = nil end -- Notify distant signals of main_pts of a change in the aspect of this signal -- function signal.notify_distants_of(main_pts, limit) atdebug("notify_distants_of",advtrains.decode_pos(main_pts),"limit",limit) if limit <= 0 then return end local dstrefs = signal.distant_refs[main_pts] atdebug("dstrefs",dstrefs,"") if dstrefs then for dst,_ in pairs(dstrefs) do -- ensure that the backref is still valid local dst_asp = signal.aspects[dst] if dst_asp and dst_asp.remote == main_pts then signal.reapply_aspect(dst) signal.notify_distants_of(dst, limit - 1) else atwarn("Distant signal backref is not purged: main =",main_pts,", distant =",dst,", remote =",dst_asp.remote,"") end end end end function signal.notify_trains(pos) local ipts, iconn = advtrains.interlocking.db.get_ip_by_signalpos(pos) if not ipts then return end local ipos = minetest.string_to_pos(ipts) -- FIXME: invalidate_all_paths_ahead does not appear to always work as expected --advtrains.invalidate_all_paths_ahead(ipos) minetest.after(0, advtrains.invalidate_all_paths, ipos) end -- Update waiting trains and distant signals about a changed signal aspect -- Must be called when a signal's aspect changes through some other means -- and not via the signal mechanism function signal.notify_on_aspect_changed(pos, skip_dst_notify) signal.notify_trains(pos) if not skip_dst_notify then signal.notify_distants_of(advtrains.encode_pos(pos), 2) end end -- Gets the stored main aspect and distant signal position for this signal -- This information equals the information last passed to set_aspect -- It does not take into consideration the actual speed signalling, please use -- get_aspect_info() for this -- pos: the position of the signal -- returns: main_aspect, dst_pos function signal.get_aspect(pos) local aspt = signal.aspects[advtrains.encode_pos(pos)] local ma,dp = signal.get_aspect_internal(pos, aspt) return ma, dp and advtrains.decode_pos(dp) end local function cache_mainaspects(ndefat) ndefat.main_aspects_lookup = {} for _,ma in ipairs(ndefat.main_aspects) do ndefat.main_aspects_lookup[ma.name] = ma end ndefat.main_aspects_lookup[signal.MASP_HALT.name] = signal.MASP_HALT.name -- halt is always defined ndefat.main_aspects_lookup[signal.MASP_DEFAULT.name] = ndefat.main_aspects[1] -- default is the first one end -- gets the main aspect. resolves named aspects to aspect table on demand function signal.get_aspect_internal(pos, aspt) -- look up node and nodedef local node = advtrains.ndb.get_node_or_nil(pos) local ndef = node and minetest.registered_nodes[node.name] if not aspt then -- oh, no main aspect, nevermind return signal.MASP_HALT, nil, node, ndef end local ndefat = ndef.advtrains or {} local masp = aspt.main or signal.MASP_HALT if type(masp) == "string" then if masp=="_halt" then masp = signal.MASP_HALT elseif masp=="_default" and not ndefat.main_aspects then -- case is fine, distant only signal masp = signal.MASP_DEFAULT else assert(ndefat.main_aspects, "With named aspects, node needs advtrains.main_aspects table!") -- resolve the main aspect from the mainaspects table if not ndefat.main_aspects_lookup then cache_mainaspects(ndefat) end masp = ndefat.main_aspects_lookup[aspt.main] or signal.MASP_DEFAULT end end -- return whatever the main aspect is return masp, aspt.remote, node, ndef end -- For the signal at pos, get the "aspect info" table. This contains the speed signalling information at this location function signal.get_aspect_info(pos) -- get aspect internal local aspt = signal.aspects[advtrains.encode_pos(pos)] local masp, remote, node, ndef = signal.get_aspect_internal(pos, aspt) -- call into ndef if ndef.advtrains and ndef.advtrains.get_aspect_info then local ai = ndef.advtrains.get_aspect_info if type(ai)=="function" then ai = ai(pos, masp) end if type(ai)=="table" then atdebug(pos,"aspectinfo",ai) return ai else error("For node "..node.name..": ndef.advtrains.get_aspect_info must be function or table") end end end -- Called when either this signal has changed its main aspect -- or when this distant signal's currently assigned main signal has changed its aspect -- It retrieves the signal's main aspect and aspect info and calls apply_aspect of the node definition -- to update the signal's appearance and aspect info -- pts: The signal position to update as encoded_pos -- returns: the return value of the nodedef call which may be aspect_info function signal.reapply_aspect(pts) -- get aspt local aspt = signal.aspects[pts] atdebug("reapply_aspect",advtrains.decode_pos(pts),"aspt",aspt) local pos = advtrains.decode_pos(pts) -- resolve mainaspect table by name local masp, remote, node, ndef = signal.get_aspect_internal(pos, aspt) -- if we have remote, resolve remote local rem_masp, rem_aspi if remote then -- register in remote signal as distant if not signal.distant_refs[remote] then signal.distant_refs[remote] = {} end signal.distant_refs[remote][pts] = true local rem_aspt = signal.aspects[remote] atdebug("resolving remote",advtrains.decode_pos(remote),"aspt",rem_aspt) local rem_pos = advtrains.decode_pos(remote) rem_masp, _, _, rem_ndef = signal.get_aspect_internal(rem_pos, rem_aspt) if rem_masp then if rem_ndef.advtrains and rem_ndef.advtrains.get_aspect_info then rem_aspi = rem_ndef.advtrains.get_aspect_info(rem_pos, rem_masp) end end end -- call into ndef atdebug("applying to",pos,": main_asp",masp,"rem_masp",rem_masp,"rem_aspi",rem_aspi) if ndef.advtrains and ndef.advtrains.apply_aspect then ndef.advtrains.apply_aspect(pos, node, masp, rem_masp, rem_aspi) end -- notify trains signal.notify_trains(pos) end -- Update this signal's aspect based on the set route -- function signal.update_route_aspect(tcbs, skip_dst_notify) if tcbs.signal then local asp = tcbs.route_aspect or "_halt" local rem = tcbs.route_remote signal.set_aspect(tcbs.signal, asp, rem, skip_dst_notify) end end -- Returns how capable the signal is with regards to aspect setting -- 0: not a signal at all -- 1: signal has get_aspect_info() but the aspect is not variable (e.g. a sign) -- 2: signal has apply_aspect() but does not have main aspects (e.g. a pure distant signal) -- 3: Full capabilities, signal has main aspects and can be used as main/shunt signal (can be start/endpoint of a route) function signal.get_signal_cap_level(pos) local node = advtrains.ndb.get_node_or_nil(pos) local ndef = node and minetest.registered_nodes[node.name] local ndefat = ndef and ndef.advtrains if ndefat and ndefat.get_aspect_info then if ndefat.apply_aspect then if ndefat.main_aspects then return 3 end return 2 end return 1 end return 0 end ---------------- function signal.can_dig(pos) local sigd = advtrains.interlocking.db.get_sigd_for_signal(pos) if sigd then local tcbs = advtrains.interlocking.db.get_tcbs(sigd) if tcbs.routeset then return false end end return true end function signal.after_dig(pos, oldnode, oldmetadata, player) -- unassign signal if necessary local sigd = advtrains.interlocking.db.get_sigd_for_signal(pos) if sigd then local tcbs = advtrains.interlocking.db.get_tcbs(sigd) advtrains.interlocking.db.set_sigd_for_signal(pos, nil) tcbs.signal = nil tcbs.route_aspect = nil tcbs.route_remote = nil minetest.chat_send_player(player:get_player_name(), "Signal has been unassigned. Name and routes are kept for reuse.") end -- TODO clear influence point advtrains.interlocking.signal.unregister_aspect(pos) end function signal.on_rightclick(pos, node, player, itemstack, pointed_thing) local pname = player:get_player_name() local control = player:get_player_control() advtrains.interlocking.show_signal_form(pos, node, pname, control.aux1) end advtrains.interlocking.signal = signal